diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2020-09-27 02:51:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-26 23:51:31 +0000 |
commit | e9c0034f4d3ee003149fe5454942bea7ff3d98be (patch) | |
tree | 0962870139ddb5802e819a5b312b42c812bcf5d4 /alacritty_terminal | |
parent | 085cc35b14e7c835e1a9add408b45da583959a6c (diff) | |
download | alacritty-e9c0034f4d3ee003149fe5454942bea7ff3d98be.tar.gz alacritty-e9c0034f4d3ee003149fe5454942bea7ff3d98be.zip |
Fix selection incorrectly expanding when scrolled in history
When doing selection expansion we were checking for wide char flags
on a cells from the bottom of the terminal instead of in a current
viewport when scrolled up in history, which was leading to expanding
more than needed if we had wide chars on the same viewport cell,
but in the bottom of the terminal.
Fixes #4257.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index d61cf7e3..00726dad 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -210,23 +210,28 @@ impl<'a, C> RenderableCellsIter<'a, C> { } let num_cols = self.grid.cols(); - let cell = self.grid[&point]; + + // Convert to absolute coordinates to adjust for the display offset. + let buffer_point = self.grid.visible_to_buffer(point); + let cell = self.grid[buffer_point]; // Check if wide char's spacers are selected. if cell.flags.contains(Flags::WIDE_CHAR) { let prev = point.sub(num_cols, 1); + let buffer_prev = self.grid.visible_to_buffer(prev); let next = point.add(num_cols, 1); // Check trailing spacer. selection.contains(next.col, next.line) // Check line-wrapping, leading spacer. - || (self.grid[&prev].flags.contains(Flags::LEADING_WIDE_CHAR_SPACER) + || (self.grid[buffer_prev].flags.contains(Flags::LEADING_WIDE_CHAR_SPACER) && selection.contains(prev.col, prev.line)) } else if cell.flags.contains(Flags::WIDE_CHAR_SPACER) { // Check if spacer's wide char is selected. let prev = point.sub(num_cols, 1); + let buffer_prev = self.grid.visible_to_buffer(prev); - if self.grid[&prev].flags.contains(Flags::WIDE_CHAR) { + if self.grid[buffer_prev].flags.contains(Flags::WIDE_CHAR) { // Check previous cell for trailing spacer. self.is_selected(prev) } else { |