summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2021-07-04 00:30:05 +0000
committerGitHub <noreply@github.com>2021-07-04 00:30:05 +0000
commit9e7655ec03aeacfd13efe3b0b304f86bf1da5e11 (patch)
treeaa3685f77aa75781783a0330cc940d75921c6aa6
parentc6ed855bfa036ffe5e3e3ea12819db6a1a25d4e1 (diff)
downloadalacritty-9e7655ec03aeacfd13efe3b0b304f86bf1da5e11.tar.gz
alacritty-9e7655ec03aeacfd13efe3b0b304f86bf1da5e11.zip
Fix crash when resizing during vi mode
Our resize clamping logic for the vi mode cursor did not correctly clamp to the viewport after the indexing change. Now it is enforced that the vi mode cursor cannot leave the visible area after a font or viewport size change.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty_terminal/src/term/mod.rs6
2 files changed, 5 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ee999003..ec786ea3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Crash/Freezes with partially visible fullwidth characters due to alt screen resize
- Incorrect vi cursor position after invoking `ScrollPageHalfUp` action
- Slow PTY read performance with extremely dense grids
+- Crash when resizing during vi mode
## 0.8.0
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 256f2f29..f25bf1ac 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -512,8 +512,10 @@ impl<T> Term<T> {
// Clamp vi cursor to viewport.
let vi_point = self.vi_mode_cursor.point;
- self.vi_mode_cursor.point.column = min(vi_point.column, Column(num_cols - 1));
- self.vi_mode_cursor.point.line = min(vi_point.line, Line(num_lines as i32 - 1));
+ let viewport_bottom = Line(-(self.grid.display_offset() as i32));
+ let viewport_top = viewport_bottom + self.bottommost_line();
+ self.vi_mode_cursor.point.line = max(min(vi_point.line, viewport_top), viewport_bottom);
+ self.vi_mode_cursor.point.column = min(vi_point.column, self.last_column());
// Reset scrolling region.
self.scroll_region = Line(0)..Line(self.screen_lines() as i32);