aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-11-14 23:17:59 +0400
committerGitHub <noreply@github.com>2023-11-14 23:17:59 +0400
commitd83d5af2b571e5dc2c5c622277096a91c04ca7eb (patch)
tree9b8ce3c569e664c91399a52d37471b07ce0d0207
parent13834d4de80b2a163f7d1838d34f67f088d2c218 (diff)
downloadalacritty-d83d5af2b571e5dc2c5c622277096a91c04ca7eb.tar.gz
alacritty-d83d5af2b571e5dc2c5c622277096a91c04ca7eb.zip
Fix Vi cursor not being dirty when scrolling
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/event.rs17
-rw-r--r--alacritty/src/input.rs50
3 files changed, 36 insertions, 32 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48a65132..7546f001 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -70,6 +70,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Crash when leaving search after resize
- Cursor being hidden after reaching cursor blinking timeout
- Message bar content getting stuck after closing with multiple messages on Wayland
+- Vi cursor position not redrawn on PageUp/PageDown without scrollback
### Removed
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index f7fd044c..e6f77e8c 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -252,6 +252,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
fn scroll(&mut self, scroll: Scroll) {
let old_offset = self.terminal.grid().display_offset() as i32;
+ let old_vi_cursor = self.terminal.vi_mode_cursor;
self.terminal.scroll_display(scroll);
let lines_changed = old_offset - self.terminal.grid().display_offset() as i32;
@@ -261,10 +262,10 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
self.search_state.display_offset_delta += lines_changed;
}
+ let vi_mode = self.terminal.mode().contains(TermMode::VI);
+
// Update selection.
- if self.terminal.mode().contains(TermMode::VI)
- && self.terminal.selection.as_ref().map_or(false, |s| !s.is_empty())
- {
+ if vi_mode && self.terminal.selection.as_ref().map_or(false, |s| !s.is_empty()) {
self.update_selection(self.terminal.vi_mode_cursor.point, Side::Right);
} else if self.mouse.left_button_state == ElementState::Pressed
|| self.mouse.right_button_state == ElementState::Pressed
@@ -274,8 +275,14 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
self.update_selection(point, self.mouse.cell_side);
}
- // Update dirty if actually scrolled or we're in the Vi mode.
- *self.dirty |= lines_changed != 0;
+ // Scrolling inside Vi mode moves the cursor, so start typing.
+ if vi_mode {
+ self.on_typing_start();
+ }
+
+ // Update dirty if actually scrolled or moved Vi cursor in Vi mode.
+ *self.dirty |=
+ lines_changed != 0 || (vi_mode && old_vi_cursor != self.terminal.vi_mode_cursor);
}
// Copy text selection.
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs
index 3c11c435..2c853488 100644
--- a/alacritty/src/input.rs
+++ b/alacritty/src/input.rs
@@ -328,37 +328,33 @@ impl<T: EventListener> Execute<T> for Action {
Action::IncreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP),
Action::DecreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP * -1.),
Action::ResetFontSize => ctx.reset_font_size(),
- Action::ScrollPageUp => {
+ Action::ScrollPageUp
+ | Action::ScrollPageDown
+ | Action::ScrollHalfPageUp
+ | Action::ScrollHalfPageDown => {
// Move vi mode cursor.
let term = ctx.terminal_mut();
- let scroll_lines = term.screen_lines() as i32;
- term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines);
-
- ctx.scroll(Scroll::PageUp);
- },
- Action::ScrollPageDown => {
- // Move vi mode cursor.
- let term = ctx.terminal_mut();
- let scroll_lines = -(term.screen_lines() as i32);
- term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines);
-
- ctx.scroll(Scroll::PageDown);
- },
- Action::ScrollHalfPageUp => {
- // Move vi mode cursor.
- let term = ctx.terminal_mut();
- let scroll_lines = term.screen_lines() as i32 / 2;
- term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines);
+ let (scroll, amount) = match self {
+ Action::ScrollPageUp => (Scroll::PageUp, term.screen_lines() as i32),
+ Action::ScrollPageDown => (Scroll::PageDown, -(term.screen_lines() as i32)),
+ Action::ScrollHalfPageUp => {
+ let amount = term.screen_lines() as i32 / 2;
+ (Scroll::Delta(amount), amount)
+ },
+ Action::ScrollHalfPageDown => {
+ let amount = -(term.screen_lines() as i32 / 2);
+ (Scroll::Delta(amount), amount)
+ },
+ _ => unreachable!(),
+ };
- ctx.scroll(Scroll::Delta(scroll_lines));
- },
- Action::ScrollHalfPageDown => {
- // Move vi mode cursor.
- let term = ctx.terminal_mut();
- let scroll_lines = -(term.screen_lines() as i32 / 2);
- term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines);
+ let old_vi_cursor = term.vi_mode_cursor;
+ term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, amount);
+ if old_vi_cursor != term.vi_mode_cursor {
+ ctx.mark_dirty();
+ }
- ctx.scroll(Scroll::Delta(scroll_lines));
+ ctx.scroll(scroll);
},
Action::ScrollLineUp => ctx.scroll(Scroll::Delta(1)),
Action::ScrollLineDown => ctx.scroll(Scroll::Delta(-1)),