summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-03-21 00:47:52 +0000
committerGitHub <noreply@github.com>2020-03-21 03:47:52 +0300
commitba05e505d51d273a92795adbac9bac5c3d888aaf (patch)
tree1b662ec524b6b45ffb810dcf51572d705178a20d
parent3d7a789fd344370d18a3da0d1f799959e51f8229 (diff)
downloadalacritty-ba05e505d51d273a92795adbac9bac5c3d888aaf.tar.gz
alacritty-ba05e505d51d273a92795adbac9bac5c3d888aaf.zip
Fix invisible selection
This resolves a bug where the very first/last cell would still be selected when both the start and the end were below/above the viewport.
-rw-r--r--alacritty_terminal/src/grid/mod.rs5
-rw-r--r--alacritty_terminal/src/term/mod.rs10
2 files changed, 8 insertions, 7 deletions
diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs
index 37cf0eb6..85d1a0bb 100644
--- a/alacritty_terminal/src/grid/mod.rs
+++ b/alacritty_terminal/src/grid/mod.rs
@@ -651,11 +651,6 @@ impl<T> Grid<T> {
}
#[inline]
- pub fn contains(&self, point: &Point) -> bool {
- self.lines > point.line && self.cols > point.col
- }
-
- #[inline]
pub fn display_offset(&self) -> usize {
self.display_offset
}
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 89c3723f..b5fced05 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -226,7 +226,6 @@ impl<'a, C> RenderableCellsIter<'a, C> {
selection: Option<SelectionRange>,
) -> RenderableCellsIter<'b, C> {
let grid = &term.grid;
- let num_cols = grid.num_cols();
let inner = grid.display_iter();
@@ -234,9 +233,16 @@ impl<'a, C> RenderableCellsIter<'a, C> {
let (limit_start, limit_end) = if span.is_block {
(span.start.col, span.end.col)
} else {
- (Column(0), num_cols - 1)
+ (Column(0), grid.num_cols() - 1)
};
+ // Do not render completely offscreen selection
+ let viewport_start = grid.display_offset();
+ let viewport_end = viewport_start + grid.num_lines().0;
+ if span.end.line >= viewport_end || span.start.line < viewport_start {
+ return None;
+ }
+
// Get on-screen lines of the selection's locations
let mut start = grid.clamp_buffer_to_visible(span.start);
let mut end = grid.clamp_buffer_to_visible(span.end);