summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-06-17 21:55:12 +0000
committerKirill Chibisov <contact@kchibisov.com>2023-06-26 13:42:07 +0400
commit5999fc72f85a97efd89a0828bbbe61084d4e69e2 (patch)
tree2774a1d3d18db32e43c257e6e878e92b3b5541fd
parentb08dd9ded3189c9f4d0a121a388b25c45c17dccf (diff)
Fix the crash when shrinking scrolled terminal
display_offset was adjusted unconditionally, thus it could go beyound the history limits, so clamp it to history like we do in grow_colums. Fixes #6862.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty_terminal/src/grid/resize.rs3
2 files changed, 4 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 365c2d1c..6e6d0bad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Hyperlink preview not being shown when the terminal has exactly 2 lines
- Crash on Windows when changing display scale factor
- Freeze with some drivers when using GLX
+- Crash when shrinking the terminal scrolled into the history
## 0.12.1
diff --git a/alacritty_terminal/src/grid/resize.rs b/alacritty_terminal/src/grid/resize.rs
index 882c0c90..92ee55d7 100644
--- a/alacritty_terminal/src/grid/resize.rs
+++ b/alacritty_terminal/src/grid/resize.rs
@@ -368,6 +368,9 @@ impl<T: GridCell + Default + PartialEq + Clone> Grid<T> {
reversed.truncate(self.max_scroll_limit + self.lines);
self.raw.replace_inner(reversed);
+ // Clamp display offset in case some lines went off.
+ self.display_offset = min(self.display_offset, self.history_size());
+
// Reflow the primary cursor, or clamp it if reflow is disabled.
if !reflow {
self.cursor.point.column = min(self.cursor.point.column, Column(columns - 1));