mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-11 13:51:01 -05:00
Fix vi cursor moving incorrectly with new output
This fixes an issue where the vi cursor would move down one line if it's positioned at the topmost visible line, while at least partially scrolled up into history, when new lines are added to the terminal. This problem is caused by using a display offset of a grid not scrolled yet when scrolling and determining a new vi cursor position.
This commit is contained in:
parent
7e736c00f6
commit
a1083d18ed
2 changed files with 23 additions and 3 deletions
|
@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Crash when hovering over a match emptied by post-processing
|
||||
- Crash when the vi cursor is on the scrollback and viewport clear is invoked
|
||||
- Freeze when the vi cursor is on the scrollback and scrollback clear is invoked
|
||||
- Vi cursor on topmost of the display moving downward when scrolled into history with active output
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -587,6 +587,8 @@ impl<T> Term<T> {
|
|||
// Scroll selection.
|
||||
self.selection = self.selection.take().and_then(|s| s.rotate(self, ®ion, lines as i32));
|
||||
|
||||
self.grid.scroll_up(®ion, lines);
|
||||
|
||||
// Scroll vi mode cursor.
|
||||
let viewport_top = Line(-(self.grid.display_offset() as i32));
|
||||
let top = if region.start == 0 { viewport_top } else { region.start };
|
||||
|
@ -594,9 +596,6 @@ impl<T> Term<T> {
|
|||
if (top <= *line) && region.end > *line {
|
||||
*line = max(*line - lines, top);
|
||||
}
|
||||
|
||||
// Scroll from origin to bottom less number of lines.
|
||||
self.grid.scroll_up(®ion, lines);
|
||||
}
|
||||
|
||||
fn deccolm(&mut self)
|
||||
|
@ -2190,6 +2189,26 @@ mod tests {
|
|||
assert_eq!(term.grid, scrolled_grid);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vi_cursor_keep_pos_on_scrollback_buffer() {
|
||||
let size = SizeInfo::new(5., 10., 1.0, 1.0, 0.0, 0.0, false);
|
||||
let mut term = Term::new(&Config::default(), size, ());
|
||||
|
||||
// Create 11 lines of scrollback.
|
||||
for _ in 0..20 {
|
||||
term.newline();
|
||||
}
|
||||
|
||||
// Enable vi mode.
|
||||
term.toggle_vi_mode();
|
||||
|
||||
term.scroll_display(Scroll::Top);
|
||||
term.vi_mode_cursor.point.line = Line(-11);
|
||||
|
||||
term.linefeed();
|
||||
assert_eq!(term.vi_mode_cursor.point.line, Line(-12));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grow_lines_updates_active_cursor_pos() {
|
||||
let mut size = SizeInfo::new(100.0, 10.0, 1.0, 1.0, 0.0, 0.0, false);
|
||||
|
|
Loading…
Reference in a new issue