Skip to content

Commit 8882f60

Browse files
committed
Fix move_cursor moving to last char of the line above all bars
The cursor needs to move to the first line (which is one less than the number of lines, as the cursor is still on the last line), and then also move to the front of that line (as it was on the last char of the last line).
1 parent 689bf09 commit 8882f60

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/draw_target.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ impl DrawState {
482482
}
483483

484484
if !self.lines.is_empty() && self.move_cursor {
485-
term.move_cursor_up(last_line_count.as_usize())?;
485+
// Move up to first line (assuming the last line doesn't contain a '\n') and then move to then front of the line
486+
term.move_cursor_up(last_line_count.as_usize().saturating_sub(1))?;
487+
term.write_str("\r")?;
486488
} else {
487489
// Fork of console::clear_last_lines that assumes that the last line doesn't contain a '\n'
488490
let n = last_line_count.as_usize();

0 commit comments

Comments
 (0)