Fix Vi cursor not being dirty when scrolling
This commit is contained in:
parent
13834d4de8
commit
d83d5af2b5
|
@ -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
|
- Crash when leaving search after resize
|
||||||
- Cursor being hidden after reaching cursor blinking timeout
|
- Cursor being hidden after reaching cursor blinking timeout
|
||||||
- Message bar content getting stuck after closing with multiple messages on Wayland
|
- Message bar content getting stuck after closing with multiple messages on Wayland
|
||||||
|
- Vi cursor position not redrawn on PageUp/PageDown without scrollback
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -252,6 +252,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
|
||||||
fn scroll(&mut self, scroll: Scroll) {
|
fn scroll(&mut self, scroll: Scroll) {
|
||||||
let old_offset = self.terminal.grid().display_offset() as i32;
|
let old_offset = self.terminal.grid().display_offset() as i32;
|
||||||
|
|
||||||
|
let old_vi_cursor = self.terminal.vi_mode_cursor;
|
||||||
self.terminal.scroll_display(scroll);
|
self.terminal.scroll_display(scroll);
|
||||||
|
|
||||||
let lines_changed = old_offset - self.terminal.grid().display_offset() as i32;
|
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;
|
self.search_state.display_offset_delta += lines_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let vi_mode = self.terminal.mode().contains(TermMode::VI);
|
||||||
|
|
||||||
// Update selection.
|
// Update selection.
|
||||||
if self.terminal.mode().contains(TermMode::VI)
|
if vi_mode && self.terminal.selection.as_ref().map_or(false, |s| !s.is_empty()) {
|
||||||
&& self.terminal.selection.as_ref().map_or(false, |s| !s.is_empty())
|
|
||||||
{
|
|
||||||
self.update_selection(self.terminal.vi_mode_cursor.point, Side::Right);
|
self.update_selection(self.terminal.vi_mode_cursor.point, Side::Right);
|
||||||
} else if self.mouse.left_button_state == ElementState::Pressed
|
} else if self.mouse.left_button_state == ElementState::Pressed
|
||||||
|| self.mouse.right_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);
|
self.update_selection(point, self.mouse.cell_side);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update dirty if actually scrolled or we're in the Vi mode.
|
// Scrolling inside Vi mode moves the cursor, so start typing.
|
||||||
*self.dirty |= lines_changed != 0;
|
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.
|
// Copy text selection.
|
||||||
|
|
|
@ -328,37 +328,33 @@ impl<T: EventListener> Execute<T> for Action {
|
||||||
Action::IncreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP),
|
Action::IncreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP),
|
||||||
Action::DecreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP * -1.),
|
Action::DecreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP * -1.),
|
||||||
Action::ResetFontSize => ctx.reset_font_size(),
|
Action::ResetFontSize => ctx.reset_font_size(),
|
||||||
Action::ScrollPageUp => {
|
Action::ScrollPageUp
|
||||||
|
| Action::ScrollPageDown
|
||||||
|
| Action::ScrollHalfPageUp
|
||||||
|
| Action::ScrollHalfPageDown => {
|
||||||
// Move vi mode cursor.
|
// Move vi mode cursor.
|
||||||
let term = ctx.terminal_mut();
|
let term = ctx.terminal_mut();
|
||||||
let scroll_lines = term.screen_lines() as i32;
|
let (scroll, amount) = match self {
|
||||||
term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines);
|
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::PageUp);
|
let old_vi_cursor = term.vi_mode_cursor;
|
||||||
},
|
term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, amount);
|
||||||
Action::ScrollPageDown => {
|
if old_vi_cursor != term.vi_mode_cursor {
|
||||||
// Move vi mode cursor.
|
ctx.mark_dirty();
|
||||||
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);
|
ctx.scroll(scroll);
|
||||||
},
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
ctx.scroll(Scroll::Delta(scroll_lines));
|
|
||||||
},
|
},
|
||||||
Action::ScrollLineUp => ctx.scroll(Scroll::Delta(1)),
|
Action::ScrollLineUp => ctx.scroll(Scroll::Delta(1)),
|
||||||
Action::ScrollLineDown => ctx.scroll(Scroll::Delta(-1)),
|
Action::ScrollLineDown => ctx.scroll(Scroll::Delta(-1)),
|
||||||
|
|
Loading…
Reference in New Issue