diff options
author | Christian Duerr <contact@christianduerr.com> | 2023-03-25 00:07:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-24 23:07:20 +0000 |
commit | 2df8f860b960d7c96efaf4f059fe2fbbdce82bcc (patch) | |
tree | 343f21f24245b6d36dc357c206d4f754359c924c /alacritty_terminal | |
parent | ef8cc5d63f34b09e46d8c733cd5a472d480f7cf1 (diff) | |
download | alacritty-2df8f860b960d7c96efaf4f059fe2fbbdce82bcc.tar.gz alacritty-2df8f860b960d7c96efaf4f059fe2fbbdce82bcc.zip |
Fix selection rotation on the last line
This fixes an issue with terminal resizes when the selection is on the
last line. Alacritty would fail to rotate lines and keep the selection
in the same line index whenever the terminal line count was grown or
shrunk.
This issue occurred due to the range passed to the selection's rotate
function still being based on the old terminal size, which caused the
initial or target state of the rotation to be outside of the terminal
bounds.
Closes #6698.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index fe9c7794..3513aa0e 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -611,6 +611,10 @@ impl<T> Term<T> { delta = cmp::min(cmp::max(delta, min_delta), history_size as i32); self.vi_mode_cursor.point.line += delta; + let is_alt = self.mode.contains(TermMode::ALT_SCREEN); + self.grid.resize(!is_alt, num_lines, num_cols); + self.inactive_grid.resize(is_alt, num_lines, num_cols); + // Invalidate selection and tabs only when necessary. if old_cols != num_cols { self.selection = None; @@ -618,14 +622,11 @@ impl<T> Term<T> { // Recreate tabs list. self.tabs.resize(num_cols); } else if let Some(selection) = self.selection.take() { - let range = Line(0)..Line(num_lines as i32); + let max_lines = cmp::max(num_lines, old_lines) as i32; + let range = Line(0)..Line(max_lines); self.selection = selection.rotate(self, &range, -delta); } - let is_alt = self.mode.contains(TermMode::ALT_SCREEN); - self.grid.resize(!is_alt, num_lines, num_cols); - self.inactive_grid.resize(is_alt, num_lines, num_cols); - // Clamp vi cursor to viewport. let vi_point = self.vi_mode_cursor.point; let viewport_top = Line(-(self.grid.display_offset() as i32)); |