Fix scroll down escape pulling lines from history

This works around a bug where the optimized version of the
`Grid::scroll_down` function would just rotate the entire grid down if
the scrolling region starts at the top of the screen, even if there is
history available.

Since rotations of scrolling regions should not affect the scrollback
history, this optimized version is now only called when the max
scrollback size is 0, making it impossible for the grid to have any
history while it is used.

Since the main usecase of this is the alternate screen buffer, which
never has any history, the performance should not be affected negatively
by this change.

Fixes #3582.
This commit is contained in:
Christian Duerr 2020-06-25 09:50:17 +00:00 committed by GitHub
parent f0775b3c89
commit 6c8966f426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 3 deletions

View File

@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Slow startup with Nvidia binary drivers on some X11 systems
- Display not scrolling when printing new lines while scrolled in history
- Regression in font rendering on macOS
- Scroll down escape (`CSI Ps T`) incorrectly pulling lines from history
## 0.4.3

View File

@ -238,13 +238,11 @@ impl<T: GridCell + Default + PartialEq + Copy> Grid<T> {
// changing the start index.
//
// To accommodate scroll regions, rows are reordered at the end.
if region.start == Line(0) {
if region.start == Line(0) && self.max_scroll_limit == 0 {
// Rotate the entire line buffer. If there's a scrolling region
// active, the bottom lines are restored in the next step.
self.raw.rotate_up(*positions);
self.decrease_scroll_limit(*positions);
// Now, restore any scroll region lines.
let lines = self.lines;
for i in IndexRange(region.end..lines) {

View File

@ -62,6 +62,7 @@ ref_tests! {
erase_chars_reset
scroll_up_reset
clear_underline
region_scroll_down
}
fn read_u8<P>(path: P) -> Vec<u8>

View File

@ -0,0 +1,46 @@
%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho -ne "\e[10000T" && sleep infinityecho "test"                           test"[?2004l
test
%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hlsls -lah-lah[?2004l
total 12K
drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 23:58 .
drwxr-xr-x 37 undeadleech undeadleech 4.0K Jun 24 23:57 ..
-rw-r--r-- 1 undeadleech undeadleech 1.3K Jun 24 23:58 alacritty.recording
%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hls -lah[?2004l
total 12K
drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 23:58 .
drwxr-xr-x 37 undeadleech undeadleech 4.0K Jun 24 23:57 ..
-rw-r--r-- 1 undeadleech undeadleech 1.9K Jun 24 23:58 alacritty.recording
%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hls -lahls -lah bin/snapshot.undo/      ./mov/.. ./../..[?2004l
total 300K
drwxr-xr-x 15 undeadleech undeadleech 4.0K Jun 24 23:53 .
drwxr-xr-x 34 undeadleech undeadleech 4.0K Jun 18 03:26 ..
-rw-r--r-- 1 undeadleech undeadleech 10 Feb 8 2019 .agignore
drwxr-xr-x 3 undeadleech undeadleech 4.0K Jun 24 23:24 alacritty
drwxr-xr-x 4 undeadleech undeadleech 4.0K Jun 24 23:24 alacritty_terminal
-rw-r--r-- 1 undeadleech undeadleech 21K Jun 24 23:24 alacritty.yml
drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 18:47 .builds
-rw-r--r-- 1 undeadleech undeadleech 116K Jun 24 23:24 Cargo.lock
-rw-r--r-- 1 undeadleech undeadleech 141 Jun 23 21:20 Cargo.toml
-rw-r--r-- 1 undeadleech undeadleech 30K Jun 24 23:53 CHANGELOG.md
drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 18:47 ci
-rw-r--r-- 1 undeadleech undeadleech 7.3K Jun 23 21:20 CONTRIBUTING.md
drwxr-xr-x 2 undeadleech undeadleech 4.0K Mar 6 00:06 .copr
drwxr-xr-x 2 undeadleech undeadleech 4.0K Feb 8 2019 docs
drwxr-xr-x 7 undeadleech undeadleech 4.0K Jun 23 21:20 extra
drwxr-xr-x 3 undeadleech undeadleech 4.0K Jun 23 21:20 font
drwxr-xr-x 8 undeadleech undeadleech 4.0K Jun 24 23:58 .git
-rw-r--r-- 1 undeadleech undeadleech 26 Jun 23 21:20 .gitattributes
drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 .github
-rw-r--r-- 1 undeadleech undeadleech 341 Jun 23 21:20 .gitignore
-rw-r--r-- 1 undeadleech undeadleech 8.9K Jun 23 21:20 INSTALL.md
-rw-r--r-- 1 undeadleech undeadleech 11K Jun 23 21:20 LICENSE-APACHE
-rw-r--r-- 1 undeadleech undeadleech 1.5K Jun 23 21:20 Makefile
-rw-r--r-- 1 undeadleech undeadleech 7.1K Jun 23 21:20 README.md
drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 res
-rw-r--r-- 1 undeadleech undeadleech 358 Mar 6 00:06 rustfmt.toml
drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 scripts
drwxr-xr-x 4 undeadleech undeadleech 4.0K Jun 20 23:09 target
-rw-r--r-- 1 undeadleech undeadleech 2.6K Jun 24 18:47 .travis.yml
%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho "test"echo -ne "\e[10000T" && sleep infinitye "\e[1  "\e[1001[e\" ne "\e[10000T" && sleep infinityne "\e[10000T" && sleep infinity[?2004l
^C
%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho -ne "\e[10000T" && sleep infinityexit                                  it[?2004l

View File

@ -0,0 +1 @@
{"history_size":10}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"width":939.0,"height":503.0,"cell_width":8.0,"cell_height":16.0,"padding_x":5.0,"padding_y":3.0,"dpr":1.0}