summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/grid/tests.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-06-23 23:29:01 +0000
committerGitHub <noreply@github.com>2019-06-23 23:29:01 +0000
commitf002171c84a2b31f156c0401b6b2423e4e77f831 (patch)
tree8a42e1d7b0192f39cfc3d4fb3d6f35d9361f5a36 /alacritty_terminal/src/grid/tests.rs
parent743d5d9c6614a807ab398473e62fad280845519e (diff)
downloadalacritty-f002171c84a2b31f156c0401b6b2423e4e77f831.tar.gz
alacritty-f002171c84a2b31f156c0401b6b2423e4e77f831.zip
Fix performance issues with text reflow
Fixes #2567. Fixes #2414.
Diffstat (limited to 'alacritty_terminal/src/grid/tests.rs')
-rw-r--r--alacritty_terminal/src/grid/tests.rs55
1 files changed, 48 insertions, 7 deletions
diff --git a/alacritty_terminal/src/grid/tests.rs b/alacritty_terminal/src/grid/tests.rs
index 2c17c9b2..ce094b96 100644
--- a/alacritty_terminal/src/grid/tests.rs
+++ b/alacritty_terminal/src/grid/tests.rs
@@ -140,7 +140,7 @@ fn shrink_reflow() {
grid[Line(0)][Column(3)] = cell('4');
grid[Line(0)][Column(4)] = cell('5');
- grid.resize(Line(1), Column(2), &mut Point::new(Line(0), Column(0)), &Cell::default());
+ grid.resize(true, Line(1), Column(2), &mut Point::new(Line(0), Column(0)), &Cell::default());
assert_eq!(grid.len(), 3);
@@ -166,8 +166,8 @@ fn shrink_reflow_twice() {
grid[Line(0)][Column(3)] = cell('4');
grid[Line(0)][Column(4)] = cell('5');
- grid.resize(Line(1), Column(4), &mut Point::new(Line(0), Column(0)), &Cell::default());
- grid.resize(Line(1), Column(2), &mut Point::new(Line(0), Column(0)), &Cell::default());
+ grid.resize(true, Line(1), Column(4), &mut Point::new(Line(0), Column(0)), &Cell::default());
+ grid.resize(true, Line(1), Column(2), &mut Point::new(Line(0), Column(0)), &Cell::default());
assert_eq!(grid.len(), 3);
@@ -193,7 +193,7 @@ fn shrink_reflow_empty_cell_inside_line() {
grid[Line(0)][Column(3)] = cell('4');
grid[Line(0)][Column(4)] = Cell::default();
- grid.resize(Line(1), Column(2), &mut Point::new(Line(0), Column(0)), &Cell::default());
+ grid.resize(true, Line(1), Column(2), &mut Point::new(Line(0), Column(0)), &Cell::default());
assert_eq!(grid.len(), 2);
@@ -205,7 +205,7 @@ fn shrink_reflow_empty_cell_inside_line() {
assert_eq!(grid[0][Column(0)], cell('3'));
assert_eq!(grid[0][Column(1)], cell('4'));
- grid.resize(Line(1), Column(1), &mut Point::new(Line(0), Column(0)), &Cell::default());
+ grid.resize(true, Line(1), Column(1), &mut Point::new(Line(0), Column(0)), &Cell::default());
assert_eq!(grid.len(), 4);
@@ -230,7 +230,7 @@ fn grow_reflow() {
grid[Line(1)][Column(0)] = cell('3');
grid[Line(1)][Column(1)] = Cell::default();
- grid.resize(Line(2), Column(3), &mut Point::new(Line(0), Column(0)), &Cell::default());
+ grid.resize(true, Line(2), Column(3), &mut Point::new(Line(0), Column(0)), &Cell::default());
assert_eq!(grid.len(), 2);
@@ -256,7 +256,7 @@ fn grow_reflow_multiline() {
grid[Line(2)][Column(0)] = cell('5');
grid[Line(2)][Column(1)] = cell('6');
- grid.resize(Line(3), Column(6), &mut Point::new(Line(0), Column(0)), &Cell::default());
+ grid.resize(true, Line(3), Column(6), &mut Point::new(Line(0), Column(0)), &Cell::default());
assert_eq!(grid.len(), 3);
@@ -279,6 +279,47 @@ fn grow_reflow_multiline() {
}
}
+#[test]
+fn grow_reflow_disabled() {
+ let mut grid = Grid::new(Line(2), Column(2), 0, cell('x'));
+ grid[Line(0)][Column(0)] = cell('1');
+ grid[Line(0)][Column(1)] = wrap_cell('2');
+ grid[Line(1)][Column(0)] = cell('3');
+ grid[Line(1)][Column(1)] = Cell::default();
+
+ grid.resize(false, Line(2), Column(3), &mut Point::new(Line(0), Column(0)), &Cell::default());
+
+ assert_eq!(grid.len(), 2);
+
+ assert_eq!(grid[1].len(), 3);
+ assert_eq!(grid[1][Column(0)], cell('1'));
+ assert_eq!(grid[1][Column(1)], wrap_cell('2'));
+ assert_eq!(grid[1][Column(2)], Cell::default());
+
+ assert_eq!(grid[0].len(), 3);
+ assert_eq!(grid[0][Column(0)], cell('3'));
+ assert_eq!(grid[0][Column(1)], Cell::default());
+ assert_eq!(grid[0][Column(2)], Cell::default());
+}
+
+#[test]
+fn shrink_reflow_disabled() {
+ let mut grid = Grid::new(Line(1), Column(5), 2, cell('x'));
+ grid[Line(0)][Column(0)] = cell('1');
+ grid[Line(0)][Column(1)] = cell('2');
+ grid[Line(0)][Column(2)] = cell('3');
+ grid[Line(0)][Column(3)] = cell('4');
+ grid[Line(0)][Column(4)] = cell('5');
+
+ grid.resize(false, Line(1), Column(2), &mut Point::new(Line(0), Column(0)), &Cell::default());
+
+ assert_eq!(grid.len(), 1);
+
+ assert_eq!(grid[0].len(), 2);
+ assert_eq!(grid[0][Column(0)], cell('1'));
+ assert_eq!(grid[0][Column(1)], cell('2'));
+}
+
fn cell(c: char) -> Cell {
let mut cell = Cell::default();
cell.c = c;