diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-02-18 04:25:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-18 04:25:50 +0000 |
commit | 6f1ddf70102acd2088cebf4c730b174d6b4570b6 (patch) | |
tree | 52842277c9fc01bb48c3be01400ce0edbe2f3650 | |
parent | fc87aaa4b10b9a5949fa2eae9e33ef66949b70d3 (diff) | |
download | alacritty-6f1ddf70102acd2088cebf4c730b174d6b4570b6.tar.gz alacritty-6f1ddf70102acd2088cebf4c730b174d6b4570b6.zip |
Fix cursor position when scrolled into history
This fixes a regression introduced in 530de00, where the terminal cursor
would move up when the user scrolled up in the terminal history, rather
than staying in place.
Fixes #4784.
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index a898ecc4..b853ceba 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -1829,14 +1829,19 @@ impl RenderableCursor { fn new<T>(term: &Term<T>) -> Self { // Cursor position. let vi_mode = term.mode().contains(TermMode::VI); - let point = if vi_mode { term.vi_mode_cursor.point } else { term.grid().cursor.point }; + let mut point = if vi_mode { + term.vi_mode_cursor.point + } else { + let mut point = term.grid.cursor.point; + point.line += term.grid.display_offset(); + point + }; // Cursor shape. - let absolute_line = term.screen_lines() - point.line - 1; - let display_offset = term.grid().display_offset(); let shape = if !vi_mode - && (!term.mode().contains(TermMode::SHOW_CURSOR) || absolute_line.0 < display_offset) + && (!term.mode().contains(TermMode::SHOW_CURSOR) || point.line >= term.screen_lines()) { + point.line = Line(0); CursorShape::Hidden } else { term.cursor_style().shape |