Commit 54cb7991be
Unregistered key
Layout: unified · split
src/message/printer.rs +16 −1
| @@ -94,7 +94,7 @@ impl<'a> TextPrinter<'a> { | ||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | fn remaining(&self) -> usize { |
| 97 | self.width - self.curr_width | |
| 97 | self.width.saturating_sub(self.curr_width) | |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /// If there is any text on the current line, start a new one. |
| @@ -276,3 +276,18 @@ impl<'a> TextPrinter<'a> { | ||
| 276 | 276 | self.text |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | ||
| 280 | #[cfg(test)] | |
| 281 | pub mod tests { | |
| 282 | use super::*; | |
| 283 | ||
| 284 | #[test] | |
| 285 | fn test_push_nobreak() { | |
| 286 | let mut printer = TextPrinter::new(5, Style::default(), false, false); | |
| 287 | printer.push_span_nobreak("hello world".into()); | |
| 288 | let text = printer.finish(); | |
| 289 | assert_eq!(text.lines.len(), 1); | |
| 290 | assert_eq!(text.lines[0].spans.len(), 1); | |
| 291 | assert_eq!(text.lines[0].spans[0].content, "hello world"); | |
| 292 | } | |
| 293 | } | |