From 05917b27405f797bca817fa68305c08b74897997 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Wed, 14 Apr 2021 19:39:35 +0000 Subject: Fix initial vi cursor position while in scrollback Fixes #4968. --- CHANGELOG.md | 4 ++++ alacritty_terminal/src/term/mod.rs | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fa883bc..ba70bd7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Regex terminal hints ([see features.md](./docs/features.md#hints)) - macOS keybinding (cmd+alt+H) hiding all windows other than Alacritty +### Changed + +- The vi mode cursor is now created in the top-left if the terminal cursor is invisible + ### Fixed - Alacritty failing to start on X11 with invalid DPI reported by XRandr 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 Term { 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. -- cgit v1.2.3-54-g00ecf