From 6b61e967390b2fa4a24f962c4771cdd82e0e9de3 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 8 Dec 2018 01:50:01 +0000 Subject: 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. --- src/grid/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/grid/mod.rs') 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 Grid { 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(); -- cgit