aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/grid
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-01-21 00:56:10 +0100
committerGitHub <noreply@github.com>2020-01-21 00:56:10 +0100
commitc84cd0fdb0335fa873f397e95a0a728be0fe15f5 (patch)
treeb4fc5dc3dc19d2bdd92c4a3396b509e988c86e65 /alacritty_terminal/src/grid
parent5e22512fe6a1a6a8e347c09bbc486408753bff95 (diff)
downloadalacritty-c84cd0fdb0335fa873f397e95a0a728be0fe15f5.tar.gz
alacritty-c84cd0fdb0335fa873f397e95a0a728be0fe15f5.zip
Fix first cell when selection is off screen
Since the expansion of the selection was done after clamping it to the grid, the selection would incorrectly move the clamped start over by one cell when the start was to the right of the original column. By resetting the side of the start point to `Left` before expanding, this can be circumvented. This also resolves a regression which broke backwards bracket selection. Fixes #3223.
Diffstat (limited to 'alacritty_terminal/src/grid')
-rw-r--r--alacritty_terminal/src/grid/mod.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs
index 53f7ebea..9c26fac0 100644
--- a/alacritty_terminal/src/grid/mod.rs
+++ b/alacritty_terminal/src/grid/mod.rs
@@ -158,22 +158,16 @@ impl<T: GridCell + PartialEq + Copy> Grid<T> {
}
}
- pub fn buffer_to_visible(&self, point: impl Into<Point<usize>>) -> Point<usize> {
+ pub fn buffer_to_visible(&self, point: impl Into<Point<usize>>) -> Option<Point<usize>> {
let mut point = point.into();
- let offset = point.line.saturating_sub(self.display_offset);
-
- if point.line < self.display_offset {
- point.col = self.num_cols();
- point.line = self.num_lines().0 - 1;
- } else if offset >= *self.num_lines() {
- point.col = Column(0);
- point.line = 0;
- } else {
- point.line = self.lines.0 - offset - 1;
+ if point.line < self.display_offset || point.line >= self.display_offset + self.lines.0 {
+ return None;
}
- point
+ point.line = self.lines.0 + self.display_offset - point.line - 1;
+
+ Some(point)
}
pub fn visible_to_buffer(&self, point: Point) -> Point<usize> {