diff options
author | Joe Wilm <joe@jwilm.com> | 2018-02-16 18:35:54 -0800 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-06-02 09:32:29 -0700 |
commit | 54d50ed3be810861d3c2fa500c3fcc8e802198d9 (patch) | |
tree | a09b08415147169b89c7a01c768041eb6424bf93 /src/grid/storage.rs | |
parent | c49a7e88f64d1421474d492cc6f51bfd30e1e4d1 (diff) | |
download | alacritty-54d50ed3be810861d3c2fa500c3fcc8e802198d9.tar.gz alacritty-54d50ed3be810861d3c2fa500c3fcc8e802198d9.zip |
Fix scrolling backwards in tmux
Diffstat (limited to 'src/grid/storage.rs')
-rw-r--r-- | src/grid/storage.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/grid/storage.rs b/src/grid/storage.rs index 0ca2f525..1588b006 100644 --- a/src/grid/storage.rs +++ b/src/grid/storage.rs @@ -62,6 +62,10 @@ impl<T> Storage<T> { (requested + self.zero) % self.len() } + fn compute_line_index(&self, requested: Line) -> usize { + ((self.len() + self.zero + *self.visible_lines) - *requested) % self.len() + } + pub fn swap(&mut self, a: usize, b: usize) { let a = self.compute_index(a); let b = self.compute_index(b); @@ -69,10 +73,9 @@ impl<T> Storage<T> { } pub fn swap_lines(&mut self, a: Line, b: Line) { - println!("visible: {}, a: {}, b: {}", self.visible_lines, a, b); - let a = self.visible_lines - a; - let b = self.visible_lines - b; - self.swap(*a, *b); + let a = self.compute_line_index(a); + let b = self.compute_line_index(b); + self.inner.swap(a, b); } pub fn iter_mut(&mut self) -> IterMut<T> { |