summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2019-12-12 16:02:07 +0100
committerGitHub <noreply@github.com>2019-12-12 16:02:07 +0100
commite99057b179cbdc0851c36575dd043fcdaa45437a (patch)
treebfe3a5dd1abb6879b40b72b5b2b82fb1f7f86c29
parent6deb274b8283b1d5afe0666d21d6093c89a0835d (diff)
downloadalacritty-e99057b179cbdc0851c36575dd043fcdaa45437a.tar.gz
alacritty-e99057b179cbdc0851c36575dd043fcdaa45437a.zip
Fix crash when resizing Alacritty
Fixes #3088.
-rw-r--r--alacritty_terminal/src/grid/storage.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/alacritty_terminal/src/grid/storage.rs b/alacritty_terminal/src/grid/storage.rs
index 8397f2c6..71b0e025 100644
--- a/alacritty_terminal/src/grid/storage.rs
+++ b/alacritty_terminal/src/grid/storage.rs
@@ -254,7 +254,7 @@ impl<T> Storage<T> {
debug_assert!(count.abs() as usize <= self.inner.len());
let len = self.inner.len();
- self.zero = self.wrap_index((self.zero as isize + count + len as isize) as usize);
+ self.zero = (self.zero as isize + count + len as isize) as usize % self.len;
}
/// Rotate the grid up, moving all existing lines down in history.
@@ -838,4 +838,22 @@ mod test {
assert_eq!(storage.zero, shrinking_expected.zero);
assert_eq!(storage.len, shrinking_expected.len);
}
+
+ #[test]
+ fn rotate_wrap_zero() {
+ let mut storage = Storage {
+ inner: vec![
+ Row::new(Column(1), &'-'),
+ Row::new(Column(1), &'-'),
+ Row::new(Column(1), &'-'),
+ ],
+ zero: 2,
+ visible_lines: Line(0),
+ len: 3,
+ };
+
+ storage.rotate(2);
+
+ assert!(storage.zero < storage.inner.len());
+ }
}