diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-03-12 00:14:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-12 03:14:00 +0300 |
commit | c2e39085e3dfed6e4ea69ea30ed85dae1d81823c (patch) | |
tree | d2d0e5fd3e86bd7eea0b82ce08aa7b6d02e46a70 /alacritty_terminal | |
parent | cc2fc0b1c36bbec7eb56d931e435e70a6e6e606c (diff) | |
download | alacritty-c2e39085e3dfed6e4ea69ea30ed85dae1d81823c.tar.gz alacritty-c2e39085e3dfed6e4ea69ea30ed85dae1d81823c.zip |
Fix crash when selecting last column
This resolves a bug where the selection start would be set to the number
of columns, causing an out of bounds when trying to index with it.
Instead of extending the selection beyond the grid when the right side
of the last column is the start of the selection, the selection will now
start in the beginning of the next line.
Fixes #3446.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/selection.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/alacritty_terminal/src/selection.rs b/alacritty_terminal/src/selection.rs index 333c31fb..f663417f 100644 --- a/alacritty_terminal/src/selection.rs +++ b/alacritty_terminal/src/selection.rs @@ -346,6 +346,11 @@ impl Selection { // Remove first cell if selection starts at the right of a cell if start.side == Side::Right && start.point != end.point { start.point.col += 1; + + // Wrap to next line when selection starts to the right of last column + if start.point.col == num_cols { + start.point = Point::new(start.point.line.saturating_sub(1), Column(0)); + } } Some(SelectionRange { start: start.point, end: end.point, is_block: false }) |