diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-04-14 19:39:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-14 19:39:35 +0000 |
commit | 05917b27405f797bca817fa68305c08b74897997 (patch) | |
tree | 630d8e1c3982bbf5de6f0ade50ade2384a6eea93 /alacritty_terminal | |
parent | 37f638fc425c357a044ab50a86dcbf1d87cea49a (diff) | |
download | alacritty-05917b27405f797bca817fa68305c08b74897997.tar.gz alacritty-05917b27405f797bca817fa68305c08b74897997.zip |
Fix initial vi cursor position while in scrollback
Fixes #4968.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 8d0fc0f8..c4425916 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -612,8 +612,15 @@ impl<T> Term<T> { self.mode ^= TermMode::VI; if self.mode.contains(TermMode::VI) { - // Reset vi mode cursor position to match primary cursor. - self.vi_mode_cursor = ViModeCursor::new(self.grid.cursor.point); + let display_offset = self.grid.display_offset() as i32; + if self.grid.cursor.point.line > self.bottommost_line() - display_offset { + // Move cursor to top-left if terminal cursor is not visible. + let point = Point::new(Line(-display_offset), Column(0)); + self.vi_mode_cursor = ViModeCursor::new(point); + } else { + // Reset vi mode cursor position to match primary cursor. + self.vi_mode_cursor = ViModeCursor::new(self.grid.cursor.point); + } } // Update UI about cursor blinking state changes. |