aboutsummaryrefslogtreecommitdiff
path: root/src/grid/storage.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2018-02-16 18:35:54 -0800
committerJoe Wilm <joe@jwilm.com>2018-03-07 09:47:21 -0800
commit40298c50e2890950a29782b247f2ec14f5b7af8b (patch)
treec3c9c18b9d4edd8961f049529fed30c0d2ce59b9 /src/grid/storage.rs
parent5c648a34aabf9c9805eced4f3b5443310a4cd461 (diff)
downloadalacritty-40298c50e2890950a29782b247f2ec14f5b7af8b.tar.gz
alacritty-40298c50e2890950a29782b247f2ec14f5b7af8b.zip
Fix scrolling backwards in tmux
Diffstat (limited to 'src/grid/storage.rs')
-rw-r--r--src/grid/storage.rs11
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> {