summaryrefslogtreecommitdiff
path: root/src/grid/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-12-08 01:50:01 +0000
committerGitHub <noreply@github.com>2018-12-08 01:50:01 +0000
commit6b61e967390b2fa4a24f962c4771cdd82e0e9de3 (patch)
treedae938e6be436ebc0f87b8e80eb43e690f4ae6ff /src/grid/mod.rs
parenta6764ba05fee785186166c0710b08eb2a5ae302c (diff)
downloadalacritty-6b61e967390b2fa4a24f962c4771cdd82e0e9de3.tar.gz
alacritty-6b61e967390b2fa4a24f962c4771cdd82e0e9de3.zip
Fix recording of ref tests
Due to the lazy initialization of lines in the Alacritty history, the recording of ref tests was broken. Because a WM would often resize the ref test window after it was spawned, some additional lines were initialized in the stored ref test. To make sure lazy initialization does not play any role in the recording and replaying of reftests, before recording and replaying the tests, the complete grid is initialized and then truncated. This should make sure that only the relevant lines are kept.
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r--src/grid/mod.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs
index b6313751..113445af 100644
--- a/src/grid/mod.rs
+++ b/src/grid/mod.rs
@@ -435,6 +435,20 @@ impl<T> Grid<T> {
self.raw.len()
}
+ #[inline]
+ pub fn history_size(&self) -> usize {
+ self.raw.len().saturating_sub(*self.lines)
+ }
+
+ /// This is used only for initializing after loading ref-tests
+ pub fn initialize_all(&mut self, template: &T)
+ where
+ T: Copy
+ {
+ let history_size = self.raw.len().saturating_sub(*self.lines);
+ self.raw.initialize(self.max_scroll_limit - history_size, Row::new(self.cols, template));
+ }
+
/// This is used only for truncating before saving ref-tests
pub fn truncate(&mut self) {
self.raw.truncate();