summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2020-09-27 02:51:31 +0300
committerGitHub <noreply@github.com>2020-09-26 23:51:31 +0000
commite9c0034f4d3ee003149fe5454942bea7ff3d98be (patch)
tree0962870139ddb5802e819a5b312b42c812bcf5d4
parent085cc35b14e7c835e1a9add408b45da583959a6c (diff)
downloadalacritty-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.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty_terminal/src/term/mod.rs11
2 files changed, 9 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7c7603e..0688a7cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,6 +44,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Crash when copying/pasting with neither pointer nor keyboard focus on Wayland
- Crash due to fd leak on Wayland
- IME window position with fullwidth characters in the search bar
+- Selection expanding over 2 characters when scrolled in history with fullwidth characters in use
## 0.5.0
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 {