summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2021-07-17 23:14:39 +0000
committerGitHub <noreply@github.com>2021-07-17 23:14:39 +0000
commitd8f0d3fabf811bedb26bb7752e4a7c2efab98d53 (patch)
tree34209356257acbec358e8064cc01eb9ede3742f9
parente447156612d3239f6b0e938043038d0ce6edaebf (diff)
downloadalacritty-d8f0d3fabf811bedb26bb7752e4a7c2efab98d53.tar.gz
alacritty-d8f0d3fabf811bedb26bb7752e4a7c2efab98d53.zip
Fix vi cursor tracking during scrolling
This resolves an issue with the vi mode cursor where it would not keep track of the content while scrolled up in history but instead slowly leave the viewport due to its absolute positioning. While an alternative solution would have been to always keep the vi mode cursor in the same spot on the viewport, keeping track of the content is not only more easy to implement but it also makes for a nicer connection between the vi mode cursor and the content below it. Fixes #5339.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty_terminal/src/term/mod.rs14
2 files changed, 15 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 50bc907b..fe304c76 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Crash when starting a vi mode search from the bottommost line
- Original scroll position not restored after canceling search
- Clipboard copy skipping non-empty cells when encountering an interrupted tab character
+- Vi mode cursor moving downward when scrolled in history with active output
## 0.8.0
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 1c29327a..b560d69e 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -562,6 +562,12 @@ impl<T> Term<T> {
self.selection =
self.selection.take().and_then(|s| s.rotate(self, &region, -(lines as i32)));
+ // Scroll vi mode cursor.
+ let line = &mut self.vi_mode_cursor.point.line;
+ if region.start <= *line && region.end > *line {
+ *line = min(*line + lines, region.end - 1);
+ }
+
// Scroll between origin and bottom
self.grid.scroll_down(&region, lines);
}
@@ -581,6 +587,14 @@ impl<T> Term<T> {
// Scroll selection.
self.selection = self.selection.take().and_then(|s| s.rotate(self, &region, lines as i32));
+ // 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 };
+ let line = &mut self.vi_mode_cursor.point.line;
+ if (top <= *line) && region.end > *line {
+ *line = max(*line - lines, top);
+ }
+
// Scroll from origin to bottom less number of lines.
self.grid.scroll_up(&region, lines);
}