Skip to content

Commit b2f7a89

Browse files
committed
fixup! Fixed bug in windows implementation
1 parent 94b7858 commit b2f7a89

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/tty/windows.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -296,27 +296,26 @@ impl ConsoleRenderer {
296296

297297
// You can't have both ENABLE_WRAP_AT_EOL_OUTPUT and
298298
// ENABLE_VIRTUAL_TERMINAL_PROCESSING. So we need to wrap manually.
299-
fn wrap_at_eol(&mut self, s: &str, mut col: usize) -> usize {
299+
fn wrap_at_eol(&mut self, s: &str, col: &mut usize) {
300300
let mut esc_seq = 0;
301301
for c in s.graphemes(true) {
302302
if c == "\n" {
303-
col = 0;
303+
*col = 0;
304304
self.buffer.push_str(c);
305305
} else {
306306
let cw = width(c, &mut esc_seq);
307-
col += cw;
308-
if col > self.cols {
307+
*col += cw;
308+
if *col > self.cols {
309309
self.buffer.push('\n');
310-
col = cw;
310+
*col = cw;
311311
}
312312
self.buffer.push_str(c);
313313
}
314314
}
315-
if col == self.cols {
315+
if *col == self.cols {
316316
self.buffer.push('\n');
317-
col = 0;
317+
*col = 0;
318318
}
319-
col
320319
}
321320
}
322321

@@ -357,21 +356,20 @@ impl Renderer for ConsoleRenderer {
357356
new_layout: &Layout,
358357
highlighter: Option<&dyn Highlighter>,
359358
) -> Result<()> {
360-
let default_prompt = new_layout.default_prompt;
361359
let cursor = new_layout.cursor;
362360
let end_pos = new_layout.end;
363361
let current_row = old_layout.cursor.row;
364362
let old_rows = old_layout.end.row;
365363

366364
self.buffer.clear();
367365
let mut col = 0;
368-
add_prompt_and_highlight(|s| { self.wrap_at_eol(s, col); },
366+
add_prompt_and_highlight(|s| { self.wrap_at_eol(s, &mut col); },
369367
highlighter, line, prompt);
370368

371369
// append hint
372370
if let Some(hint) = hint {
373371
if let Some(highlighter) = highlighter {
374-
self.wrap_at_eol(&highlighter.highlight_hint(hint), col);
372+
self.wrap_at_eol(&highlighter.highlight_hint(hint), &mut col);
375373
} else {
376374
self.buffer.push_str(hint);
377375
}

0 commit comments

Comments
 (0)