Skip to content

Commit 57965d6

Browse files
committed
Simplify behaiver of Screen.actual.cursor
For most of Screen::update, Screen.actual.cursor was measured from the start of the rendered commandline. However, at the end of the function, because of cursor inability to move the viewport up, `self.r#move(0, 0);` implicitly changed Screen.actual.cursor to be measured from the minimum of the viewport and the start of the commandline. Change this to always measure cursor position from the start of the commandline.
1 parent 141f9c7 commit 57965d6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/screen.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub struct ScreenData {
155155
screen_width: Option<usize>,
156156

157157
/// Virtual cursor position used for writing to `line_datas`,
158-
/// and also the viewport final cursor position.
158+
/// and also final cursor position from the start of rendered commandline.
159159
cursor: Cursor,
160160

161161
/// Number of prompt lines rendered on the screen.
@@ -494,10 +494,8 @@ impl Screen {
494494
mut cursor,
495495
scroll_amount,
496496
} = scrolled_cursor;
497-
if scroll_amount != 0 {
498-
if !is_final_rendering {
499-
self.desired.line_datas = self.desired.line_datas.split_off(scroll_amount);
500-
}
497+
if scroll_amount != 0 && !is_final_rendering {
498+
self.desired.line_datas = self.desired.line_datas.split_off(scroll_amount);
501499
cursor.y -= scroll_amount;
502500
}
503501
cursor
@@ -1321,7 +1319,7 @@ impl Screen {
13211319
// Don't do it when running in midnight_commander because of
13221320
// https://midnight-commander.org/ticket/4258.
13231321
if !MIDNIGHT_COMMANDER_HACK.load() {
1324-
self.r#move(0, 0);
1322+
self.r#move(0, self.actual.cursor.y);
13251323
}
13261324

13271325
// Clear remaining lines (if any) if we haven't cleared the screen.

0 commit comments

Comments
 (0)