summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/grid/resize.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-07-01 06:58:06 +0000
committerGitHub <noreply@github.com>2020-07-01 09:58:06 +0300
commitbc60782e424359d818a22ffa2ffa3c2dc88ab6fe (patch)
tree3fb6548a20e8c61badefd4aa91396c4eecce6c4d /alacritty_terminal/src/grid/resize.rs
parent8688e47ddb932818d4e0992299c3cbbff6cf0572 (diff)
downloadalacritty-bc60782e424359d818a22ffa2ffa3c2dc88ab6fe.tar.gz
alacritty-bc60782e424359d818a22ffa2ffa3c2dc88ab6fe.zip
Fix reflow of empty wrapped cursor line
This bug was caused by trying to grow the terminal while the cursor line was wrapped but entirely empty. Resizing the terminal now accounts for the position of the deleted line and moves the cursor up only when the line deleted was above it. The deletion of the line was caused by the shell redrawing itself whenever the cursor is moved. Fixes #3583.
Diffstat (limited to 'alacritty_terminal/src/grid/resize.rs')
-rw-r--r--alacritty_terminal/src/grid/resize.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/alacritty_terminal/src/grid/resize.rs b/alacritty_terminal/src/grid/resize.rs
index 796c5859..95a8c2fc 100644
--- a/alacritty_terminal/src/grid/resize.rs
+++ b/alacritty_terminal/src/grid/resize.rs
@@ -67,10 +67,12 @@ impl<T: GridCell + Default + PartialEq + Copy> Grid<T> {
self.scroll_up(&(Line(0)..self.lines), Line(required_scrolling), T::default());
// Clamp cursors to the new viewport size.
- self.saved_cursor.point.line = min(self.saved_cursor.point.line, target - 1);
self.cursor.point.line = min(self.cursor.point.line, target - 1);
}
+ // Clamp saved cursor, since only primary cursor is scrolled into viewport.
+ self.saved_cursor.point.line = min(self.saved_cursor.point.line, target - 1);
+
self.raw.rotate((self.lines - target).0 as isize);
self.raw.shrink_visible_lines(target);
self.lines = target;
@@ -135,7 +137,8 @@ impl<T: GridCell + Default + PartialEq + Copy> Grid<T> {
// Reflow cells to previous row.
last_row.append(&mut cells);
- if row.is_empty() {
+ let cursor_buffer_line = (self.lines - self.cursor.point.line - 1).0;
+ if row.is_clear() && (i != cursor_buffer_line || row.len() == 0) {
if i + reversed.len() < self.lines.0 {
// Add new line and move everything up if we can't pull from history.
self.saved_cursor.point.line.0 = self.saved_cursor.point.line.saturating_sub(1);
@@ -144,6 +147,16 @@ impl<T: GridCell + Default + PartialEq + Copy> Grid<T> {
} else {
// Since we removed a line, rotate down the viewport.
self.display_offset = self.display_offset.saturating_sub(1);
+
+ // Rotate cursors down if content below them was pulled from history.
+ if i < cursor_buffer_line {
+ self.cursor.point.line += 1;
+ }
+
+ let saved_buffer_line = (self.lines - self.saved_cursor.point.line - 1).0;
+ if i < saved_buffer_line {
+ self.saved_cursor.point.line += 1;
+ }
}
// Don't push line into the new buffer.