From bbe276e3a80571dd0d72a9b32fb7bed38c3be868 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Thu, 12 Oct 2017 19:07:49 -0700 Subject: Back Grid with VecDeque VecDeque offers improved performance beyond a plain Vec for common scrolling situations (full screen scroll). Additionally, VecDeque is necessary for performant scrollback since recycling old rows for a Vec would be expensive (push/pop front would shift entire vec). --- tests/ref.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/ref.rs') diff --git a/tests/ref.rs b/tests/ref.rs index b8587955..2a093704 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -84,7 +84,7 @@ fn ref_test(dir: &Path) { } if grid != *terminal.grid() { - for (i, row) in terminal.grid().iter_rows().enumerate() { + for (i, row) in terminal.grid().lines().enumerate() { for (j, cell) in row.iter().enumerate() { let original_cell = &grid[Line(i)][Column(j)]; if *original_cell != *cell { -- cgit From 4ed25009c49b5963d91f4e3c7ead0f4a5b678980 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Thu, 12 Oct 2017 20:29:35 -0700 Subject: Remove some unused methods and impls --- tests/ref.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/ref.rs') diff --git a/tests/ref.rs b/tests/ref.rs index 2a093704..6836a9f5 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -6,6 +6,7 @@ use std::io::{self, Read}; use std::path::Path; use alacritty::Grid; +use alacritty::grid::IndexRegion; use alacritty::Term; use alacritty::ansi; use alacritty::index::{Line, Column}; @@ -84,7 +85,7 @@ fn ref_test(dir: &Path) { } if grid != *terminal.grid() { - for (i, row) in terminal.grid().lines().enumerate() { + for (i, row) in terminal.grid().region(..).into_iter().enumerate() { for (j, cell) in row.iter().enumerate() { let original_cell = &grid[Line(i)][Column(j)]; if *original_cell != *cell { -- cgit From 2234234ca9a2ab0d7eccd46893cbe6799b051aba Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 14 Apr 2018 17:21:48 +0200 Subject: Enable history comparison in ref-tests Previously ref-tests just ignored the scrollback history to keep the old tests working, this would lead to new tests which rely on scrollback history to succeeed even though they should not. This has been fixed and it is now possible to create ref-tests with and without scrollback history. When available the scrollback history is compared, but the old tests still work without having to adjust them. This fixes #1244. --- tests/ref.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'tests/ref.rs') diff --git a/tests/ref.rs b/tests/ref.rs index 6836a9f5..306b71a9 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -9,10 +9,11 @@ use alacritty::Grid; use alacritty::grid::IndexRegion; use alacritty::Term; use alacritty::ansi; -use alacritty::index::{Line, Column}; +use alacritty::index::Column; use alacritty::term::Cell; use alacritty::term::SizeInfo; use alacritty::util::fmt::{Red, Green}; +use alacritty::config::Config; macro_rules! ref_tests { ($($name:ident)*) => { @@ -47,6 +48,7 @@ ref_tests! { vttest_scroll vttest_tab_clear_set zsh_tab_completion + history } fn read_u8

(path: P) -> Vec @@ -77,7 +79,10 @@ fn ref_test(dir: &Path) { let size: SizeInfo = json::from_str(&serialized_size).unwrap(); let grid: Grid = json::from_str(&serialized_grid).unwrap(); - let mut terminal = Term::new(&Default::default(), size); + let mut config: Config = Default::default(); + config.set_history(grid.history_size() as u32); + + let mut terminal = Term::new(&config, size); let mut parser = ansi::Processor::new(); for byte in recording { @@ -85,10 +90,11 @@ fn ref_test(dir: &Path) { } if grid != *terminal.grid() { - for (i, row) in terminal.grid().region(..).into_iter().enumerate() { - for (j, cell) in row.iter().enumerate() { - let original_cell = &grid[Line(i)][Column(j)]; - if *original_cell != *cell { + for i in 0..(grid.num_lines().0 + grid.history_size()) { + for j in 0..grid.num_cols().0 { + let cell = terminal.grid()[i][Column(j)]; + let original_cell = grid[i][Column(j)]; + if original_cell != cell { println!("[{i}][{j}] {original:?} => {now:?}", i=i, j=j, original=Green(original_cell), now=Red(cell)); } -- cgit From d39370514a127faa05832701bb4a56fc6811de9d Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 14 Apr 2018 17:37:57 +0200 Subject: Reset grid content when running `reset` In the current scrollback PR the `reset` command does not affect the scrollback history. To make sure the terminal is properly reset, it should clear the scrollback history. This commit fixes this by creating a new and empty grid whenever `reset` is executed. It takes the current dimensions and history size from the old grid. Right now there's an empty ref-test called `grid_reset` without any content, this should be implemented once #1244 is resolved. This fixes #1242. --- tests/ref.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/ref.rs') diff --git a/tests/ref.rs b/tests/ref.rs index 306b71a9..0c8c9768 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -49,6 +49,7 @@ ref_tests! { vttest_tab_clear_set zsh_tab_completion history + grid_reset } fn read_u8

(path: P) -> Vec -- cgit From 8168d85a21b1a67b9cf25808c4e3e01f7437b50d Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 28 Apr 2018 16:15:21 +0200 Subject: Improve storage comparison algorithm Instead of iterating over the raw storage vector because the offsets don't allow direct comparison, the comparison is now done in chunks. Based on benchmarking this is a lot more efficient than using split_off + append or iterating over the elements of the buffer. The `history_size` field has also been removed from the storage structure because it can be easily calculated by substracting the number of visible lines from the length of the raw storage vector. --- tests/ref.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tests/ref.rs') diff --git a/tests/ref.rs b/tests/ref.rs index 0c8c9768..9ea0b80c 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -6,7 +6,6 @@ use std::io::{self, Read}; use std::path::Path; use alacritty::Grid; -use alacritty::grid::IndexRegion; use alacritty::Term; use alacritty::ansi; use alacritty::index::Column; @@ -81,7 +80,7 @@ fn ref_test(dir: &Path) { let grid: Grid = json::from_str(&serialized_grid).unwrap(); let mut config: Config = Default::default(); - config.set_history(grid.history_size() as u32); + config.set_history((grid.len() - grid.num_lines().0) as u32); let mut terminal = Term::new(&config, size); let mut parser = ansi::Processor::new(); @@ -91,7 +90,7 @@ fn ref_test(dir: &Path) { } if grid != *terminal.grid() { - for i in 0..(grid.num_lines().0 + grid.history_size()) { + for i in 0..grid.len() { for j in 0..grid.num_cols().0 { let cell = terminal.grid()[i][Column(j)]; let original_cell = grid[i][Column(j)]; -- cgit From ac93f6d03198c1826dbed60fa8283aeb8d1a577d Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 15 May 2018 22:36:14 +0200 Subject: Truncate invisible lines before storing ref-tests Because there is no good way to store invisible lines in a backwards- and forwards-compatible way, they buffer now gets truncated before dumping the state of a grid when creating a ref-test. This involved a few workaround of which a few required adding additional methods which are only used in ref-tests, these should be minimal though. Since this required the creation of a truncation method anyways, some logic has been added which automatically truncates the invisible buffer when there are more than X (set to 100) invisible lines. This should not impact performance because it rarely occurs, but it could save a bit of memory when the history size is shrunk during runtime (see #1293). This also adds an optional `config.json` file to the ref-test output where it is possible to manually specify variables which should override config defaults, this has been used only for history_size so far. Creating a new ref-test does also still work, so there was no regression here, if history size is altered, the config.json just has to be created manually with the content `{"history_size":HIST_SIZE}`, where `HIST_SIZE` is the desired history size. --- tests/ref.rs | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'tests/ref.rs') diff --git a/tests/ref.rs b/tests/ref.rs index 9ea0b80c..74cac6fa 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -1,5 +1,7 @@ -extern crate alacritty; +#[macro_use] +extern crate serde_derive; extern crate serde_json as json; +extern crate alacritty; use std::fs::File; use std::io::{self, Read}; @@ -61,26 +63,32 @@ fn read_u8

(path: P) -> Vec res } -fn read_string

(path: P) -> String +fn read_string

(path: P) -> Result where P: AsRef { let mut res = String::new(); - File::open(path.as_ref()).unwrap() - .read_to_string(&mut res).unwrap(); + File::open(path.as_ref()).and_then(|mut f| f.read_to_string(&mut res))?; - res + Ok(res) +} + +#[derive(Deserialize, Default)] +struct RefConfig { + history_size: u32, } fn ref_test(dir: &Path) { let recording = read_u8(dir.join("alacritty.recording")); - let serialized_size = read_string(dir.join("size.json")); - let serialized_grid = read_string(dir.join("grid.json")); + let serialized_size = read_string(dir.join("size.json")).unwrap(); + let serialized_grid = read_string(dir.join("grid.json")).unwrap(); + let serialized_cfg = read_string(dir.join("config.json")).unwrap_or_default(); let size: SizeInfo = json::from_str(&serialized_size).unwrap(); let grid: Grid = json::from_str(&serialized_grid).unwrap(); + let ref_config: RefConfig = json::from_str(&serialized_cfg).unwrap_or_default(); let mut config: Config = Default::default(); - config.set_history((grid.len() - grid.num_lines().0) as u32); + config.set_history(ref_config.history_size); let mut terminal = Term::new(&config, size); let mut parser = ansi::Processor::new(); @@ -89,7 +97,11 @@ fn ref_test(dir: &Path) { parser.advance(&mut terminal, byte, &mut io::sink()); } - if grid != *terminal.grid() { + // Truncate invisible lines from the grid + let mut term_grid = terminal.grid().clone(); + term_grid.truncate(); + + if grid != term_grid { for i in 0..grid.len() { for j in 0..grid.num_cols().0 { let cell = terminal.grid()[i][Column(j)]; @@ -104,5 +116,5 @@ fn ref_test(dir: &Path) { panic!("Ref test failed; grid doesn't match"); } - assert_eq!(grid, *terminal.grid()); + assert_eq!(grid, term_grid); } -- cgit