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.
This commit is contained in:
Kirill Chibisov 2020-09-27 02:51:31 +03:00 committed by GitHub
parent 085cc35b14
commit e9c0034f4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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 {