From c2e39085e3dfed6e4ea69ea30ed85dae1d81823c Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Thu, 12 Mar 2020 00:14:00 +0000 Subject: [PATCH] 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. --- alacritty_terminal/src/selection.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/alacritty_terminal/src/selection.rs b/alacritty_terminal/src/selection.rs index 333c31f..f663417 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 })