summaryrefslogtreecommitdiff
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
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.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty_terminal/src/grid/mod.rs5
-rw-r--r--alacritty_terminal/src/grid/resize.rs17
-rw-r--r--alacritty_terminal/src/grid/row.rs3
-rw-r--r--alacritty_terminal/src/term/mod.rs4
5 files changed, 20 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0297b1e1..8109b100 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Regression in font rendering on macOS
- Scroll down escape (`CSI Ps T`) incorrectly pulling lines from history
- Dim escape (`CSI 2 m`) support for truecolor text
+- Incorrectly deleted lines when increasing width with a prompt wrapped using spaces
## 0.4.3
diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs
index fd555d1b..5178ed99 100644
--- a/alacritty_terminal/src/grid/mod.rs
+++ b/alacritty_terminal/src/grid/mod.rs
@@ -187,11 +187,6 @@ impl<T: GridCell + Default + PartialEq + Copy> Grid<T> {
Point { line: self.lines.0 + self.display_offset - point.line.0 - 1, col: point.col }
}
- /// Return the cursor position in buffer coordinates.
- pub fn cursor_buffer_point(&self) -> Point<usize> {
- Point { line: self.lines.0 - self.cursor.point.line.0 - 1, col: self.cursor.point.col }
- }
-
/// Update the size of the scrollback history.
pub fn update_history(&mut self, history_size: usize) {
let current_history_size = self.history_size();
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.
diff --git a/alacritty_terminal/src/grid/row.rs b/alacritty_terminal/src/grid/row.rs
index bd5411aa..7846a7ae 100644
--- a/alacritty_terminal/src/grid/row.rs
+++ b/alacritty_terminal/src/grid/row.rs
@@ -130,8 +130,9 @@ impl<T> Row<T> {
self.inner = vec;
}
+ /// Check if all cells in the row are empty.
#[inline]
- pub fn is_empty(&self) -> bool
+ pub fn is_clear(&self) -> bool
where
T: GridCell,
{
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index bed3f1bc..16e4de92 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -1775,7 +1775,7 @@ impl<T: EventListener> Handler for Term<T> {
},
}
- let cursor_buffer_line = self.grid.cursor_buffer_point().line;
+ let cursor_buffer_line = (self.grid.num_lines() - self.grid.cursor.point.line - 1).0;
self.selection = self
.selection
.take()
@@ -1858,7 +1858,7 @@ impl<T: EventListener> Handler for Term<T> {
let template = self.grid.cursor.template;
let num_lines = self.grid.num_lines().0;
- let cursor_buffer_line = self.grid.cursor_buffer_point().line;
+ let cursor_buffer_line = num_lines - self.grid.cursor.point.line.0 - 1;
match mode {
ansi::ClearMode::Above => {