From 25640a8a81d28384aa58a000c91832f7159d60a9 Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Sat, 1 Feb 2020 20:25:07 +0900 Subject: [PATCH] Fix bug where max_width is not initialized after line break --- src/printer.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/printer.rs b/src/printer.rs index 2729b884..cf5b7987 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -471,7 +471,7 @@ impl<'a> Printer for InteractivePrinter<'a> { &mut cursor_total, ); - let max_width = cursor_max - cursor; + let mut max_width = cursor_max - cursor; // line buffer (avoid calling write! for every character) let mut line_buf = String::with_capacity(max_width * 4); @@ -505,8 +505,6 @@ impl<'a> Printer for InteractivePrinter<'a> { } } - cursor = 0; - // It wraps. write!( handle, @@ -525,6 +523,9 @@ impl<'a> Printer for InteractivePrinter<'a> { panel_wrap.clone().unwrap() )?; + cursor = 0; + max_width = cursor_max; + line_buf.clear(); current_width = cw; }