mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 03:01:15 -03:00
Simplify behavior of ScreenData.cursor
Let `y=0` be the first line of the rendered commandline. Then, in final
rendering, the final value of the desired cursor was measured from
`y=scroll_amount`. This wasn't a problem because
```
if !MIDNIGHT_COMMANDER_HACK.load() {
self.r#move(0, 0);
}
```
implicitly changed the actual cursor to be measured from `y=0` to `y=scroll_amount`.
This happened because the cursor moved to `y=scroll_amount` but had its
`y` value set to 0. Since the actual and desired cursors were both measured
from the same line, the code was correct, just unintuitive.
Change this to always measure cursor position from the start of the
rendered commandline.
This commit is contained in:
committed by
Johannes Altmanninger
parent
f7359751c9
commit
c7fdb8dc6b
@@ -155,7 +155,7 @@ pub struct ScreenData {
|
||||
screen_width: Option<usize>,
|
||||
|
||||
/// Virtual cursor position used for writing to `line_datas`,
|
||||
/// and also the viewport final cursor position.
|
||||
/// and also final cursor position from the start of rendered commandline.
|
||||
cursor: Cursor,
|
||||
|
||||
/// Number of prompt lines rendered on the screen.
|
||||
@@ -494,10 +494,8 @@ struct ScrolledCursor {
|
||||
mut cursor,
|
||||
scroll_amount,
|
||||
} = scrolled_cursor;
|
||||
if scroll_amount != 0 {
|
||||
if !is_final_rendering {
|
||||
self.desired.line_datas = self.desired.line_datas.split_off(scroll_amount);
|
||||
}
|
||||
if scroll_amount != 0 && !is_final_rendering {
|
||||
self.desired.line_datas = self.desired.line_datas.split_off(scroll_amount);
|
||||
cursor.y -= scroll_amount;
|
||||
}
|
||||
cursor
|
||||
@@ -1322,7 +1320,7 @@ fn s_line(zelf: &Screen, i: usize) -> &Line {
|
||||
// Don't do it when running in midnight_commander because of
|
||||
// https://midnight-commander.org/ticket/4258.
|
||||
if !MIDNIGHT_COMMANDER_HACK.load() {
|
||||
self.r#move(0, 0);
|
||||
self.r#move(0, self.actual.cursor.y);
|
||||
}
|
||||
|
||||
// Clear remaining lines (if any) if we haven't cleared the screen.
|
||||
|
||||
Reference in New Issue
Block a user