aboutsummaryrefslogtreecommitdiff
path: root/src/grid
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-04-14 17:21:48 +0200
committerJoe Wilm <joe@jwilm.com>2018-06-02 09:56:50 -0700
commit2234234ca9a2ab0d7eccd46893cbe6799b051aba (patch)
tree369d5a5b9855b7f3c08d5f8a3836ed9c47203ce5 /src/grid
parentd8bda60c3d8f906f1018012f4a55c7b894afb4b7 (diff)
downloadalacritty-2234234ca9a2ab0d7eccd46893cbe6799b051aba.tar.gz
alacritty-2234234ca9a2ab0d7eccd46893cbe6799b051aba.zip
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.
Diffstat (limited to 'src/grid')
-rw-r--r--src/grid/mod.rs21
-rw-r--r--src/grid/storage.rs10
2 files changed, 20 insertions, 11 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs
index ac54f580..b6cff604 100644
--- a/src/grid/mod.rs
+++ b/src/grid/mod.rs
@@ -52,9 +52,23 @@ impl<T> Deref for Indexed<T> {
impl<T: PartialEq> ::std::cmp::PartialEq for Grid<T> {
fn eq(&self, other: &Self) -> bool {
+ // Compare raw grid content
+ // TODO: This is pretty inefficient but only used in tests
+ let mut raw_match = true;
+ for i in 0..(self.lines.0 + self.history_size) {
+ for j in 0..self.cols.0 {
+ if self[i][Column(j)] != other[i][Column(j)] {
+ raw_match = false;
+ break;
+ }
+ }
+ }
+
+ // Compare struct fields and check result of grid comparison
self.cols.eq(&other.cols) &&
self.lines.eq(&other.lines) &&
- self.raw.eq(&other.raw)
+ self.history_size.eq(&other.history_size) &&
+ raw_match
}
}
@@ -88,6 +102,10 @@ pub struct Grid<T> {
/// Selected region
#[serde(skip)]
pub selection: Option<Selection>,
+
+ /// Maximum number of lines in the scrollback history
+ #[serde(default)]
+ history_size: usize,
}
pub struct GridIterator<'a, T: 'a> {
@@ -132,6 +150,7 @@ impl<T: Copy + Clone> Grid<T> {
display_offset: 0,
scroll_limit: 0,
selection: None,
+ history_size: scrollback,
}
}
diff --git a/src/grid/storage.rs b/src/grid/storage.rs
index fb66b0c3..50ce6aa5 100644
--- a/src/grid/storage.rs
+++ b/src/grid/storage.rs
@@ -22,16 +22,6 @@ pub struct Storage<T> {
visible_lines: Line,
}
-impl<T: PartialEq> ::std::cmp::PartialEq for Storage<T> {
- fn eq(&self, other: &Self) -> bool {
- let mut equal = true;
- for i in IndexRange(Line(0) .. self.visible_lines) {
- equal = equal && (self[i] == other[i])
- }
- equal
- }
-}
-
impl<T> Storage<T> {
#[inline]
pub fn with_capacity(cap: usize, lines: Line) -> Storage<T> {