diff options
author | Christian Duerr <contact@christianduerr.com> | 2018-04-22 14:39:55 +0200 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-06-02 09:56:50 -0700 |
commit | fe749cf0adee1be93fd3473f6d3533fbe892e3dc (patch) | |
tree | ae56f0007a3e6c957eda9ed7edc62f15538b0463 /src/grid/mod.rs | |
parent | e615d112fb9fffe46121bd9068498b07c4733fa8 (diff) | |
download | alacritty-fe749cf0adee1be93fd3473f6d3533fbe892e3dc.tar.gz alacritty-fe749cf0adee1be93fd3473f6d3533fbe892e3dc.zip |
Fix order of lines after resize
There was an issue where the lines would be messed up when the terminal
was resized, this was because lines were just added/removed at the end
of the buffer instead of the actual end of the terminal (since the end
of the terminal might be in the middle of the buffer).
This has been fixed by relying on `self.zero` to determine the position
of the start of the terminal and then calculating where lines have to be
inserted/removed.
Some tests have also been added with documentation that should make it
a little easier to understand how the process works and how the raw
buffer is layed out.
This should all work no matter how big the scrollback history and even
when the currenty viewport is not at the bottom of the terminal output.
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r-- | src/grid/mod.rs | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs index e42e5cfa..bc288e3b 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -240,16 +240,9 @@ impl<T: Copy + Clone> Grid<T> { let lines_added = new_line_count - self.lines; // Need to "resize" before updating buffer - self.raw.set_visible_lines(new_line_count); + self.raw.grow_visible_lines(new_line_count, Row::new(self.cols, template)); self.lines = new_line_count; - // Fill up the history with empty lines - if self.raw.len() < self.raw.capacity() { - for _ in self.raw.len()..self.raw.capacity() { - self.raw.push(Row::new(self.cols, &template)); - } - } - // Add new lines to bottom self.scroll_up(&(Line(0)..new_line_count), lines_added, template); @@ -277,7 +270,7 @@ impl<T: Copy + Clone> Grid<T> { self.selection = None; self.raw.rotate(*prev as isize - *target as isize); - self.raw.set_visible_lines(target); + self.raw.shrink_visible_lines(target); self.lines = target; } |