diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-03-07 22:17:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-07 22:17:38 +0000 |
commit | 64a3115648d354731ef08c2de8b2168b9326b7b5 (patch) | |
tree | c9121ed2e475ed2b531d8f8a1c01d9f000d74769 /alacritty_terminal/src/grid/tests.rs | |
parent | de5d770416eb6ea5567b2b46874b8e35b084b9e1 (diff) | |
download | alacritty-64a3115648d354731ef08c2de8b2168b9326b7b5.tar.gz alacritty-64a3115648d354731ef08c2de8b2168b9326b7b5.zip |
Fix selection with invisible start and end
This resolves an issue with the selection clamping, where no selection
would be rendered at all when the start was above the viewport while the
end was below it.
Diffstat (limited to 'alacritty_terminal/src/grid/tests.rs')
-rw-r--r-- | alacritty_terminal/src/grid/tests.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/alacritty_terminal/src/grid/tests.rs b/alacritty_terminal/src/grid/tests.rs index e4fdad5c..e8f4fb8d 100644 --- a/alacritty_terminal/src/grid/tests.rs +++ b/alacritty_terminal/src/grid/tests.rs @@ -37,6 +37,40 @@ impl GridCell for usize { } } +#[test] +fn grid_clamp_buffer_point() { + let mut grid = Grid::new(Line(10), Column(10), 1_000, 0); + grid.display_offset = 5; + + let point = grid.clamp_buffer_to_visible(Point::new(10, Column(3))); + assert_eq!(point, Point::new(Line(4), Column(3))); + + let point = grid.clamp_buffer_to_visible(Point::new(15, Column(3))); + assert_eq!(point, Point::new(Line(0), Column(0))); + + let point = grid.clamp_buffer_to_visible(Point::new(4, Column(3))); + assert_eq!(point, Point::new(Line(9), Column(9))); + + grid.display_offset = 0; + + let point = grid.clamp_buffer_to_visible(Point::new(4, Column(3))); + assert_eq!(point, Point::new(Line(5), Column(3))); +} + +#[test] +fn visible_to_buffer() { + let mut grid = Grid::new(Line(10), Column(10), 1_000, 0); + grid.display_offset = 5; + + let point = grid.visible_to_buffer(Point::new(Line(4), Column(3))); + assert_eq!(point, Point::new(10, Column(3))); + + grid.display_offset = 0; + + let point = grid.visible_to_buffer(Point::new(Line(5), Column(3))); + assert_eq!(point, Point::new(4, Column(3))); +} + // Scroll up moves lines upwards #[test] fn scroll_up() { |