diff options
author | Canop <cano.petrole@gmail.com> | 2020-01-10 22:20:22 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-01-10 22:20:22 +0100 |
commit | 9ac04f2a734da1160b6f4b7866d9e642fb5a41a5 (patch) | |
tree | a4f36144946b1b9f1c4ad6f8da024e189d99c8c8 | |
parent | f340e5f727bff6f773b6f8a029aaed3315b5c176 (diff) |
fix scroll adjustement when using the arrow keysv0.11.6
(when there's a scrollbar)
Fix #112
-rw-r--r-- | CHANGELOG.md | 8 | ||||
-rw-r--r-- | src/flat_tree.rs | 18 |
2 files changed, 19 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a45f05..e6f9918 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ ### master -- backspace was previously bind to back if not consumed by input. This is removed -- fix unsignificative events interpreted as previous event repetition -- fix wrong background applied below sizes +- backspace was previously bound to :back if not consumed by input. This is removed +- fix unsignificative event interpreted as previous event repetition +- fix wrong background applied on sizes in tree display - allow env vars used in verb execution to contain parameters (fix #114) +- allow the use of arrow keys as triggers for verbs (fix #121) +- fix scroll adjustement when using the arrow keys (when there's a scrollbar) (fix #112) <a name="v0.11.5"></a> ### v0.11.5 - 2020-01-10 diff --git a/src/flat_tree.rs b/src/flat_tree.rs index 8822226..08fdceb 100644 --- a/src/flat_tree.rs +++ b/src/flat_tree.rs @@ -287,10 +287,20 @@ impl Tree { // we adjust the scroll let l = l as i32; let sel = self.selection as i32; - if dy < 0 && sel < self.scroll + 5 { - self.scroll = (self.scroll + 2 * dy).max(0); - } else if dy > 0 && l > page_height && sel > self.scroll + page_height - 5 { - self.scroll += 2 * dy; + if l > page_height { + if dy < 0 { // -1 + if sel == l - 1 { // cycling + self.scroll = l - page_height; + } else if sel < self.scroll + 5 { + self.scroll = (self.scroll + 2 * dy).max(0); + } + } else { // +1 + if sel == 0 { // cycling brought us back to top + self.scroll = 0; + } else if sel > self.scroll + page_height - 5 { + self.scroll = (self.scroll + 2 * dy).min(l - page_height); + } + } } } pub fn try_scroll(&mut self, dy: i32, page_height: i32) { |