diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-01-22 21:58:17 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-01-22 21:58:17 +0100 |
commit | d5404b15ff258663b8fa24907fdc1e327d9c4cb7 (patch) | |
tree | 83e523528a56c621d2a2096732ed4f1e35c3c026 /src | |
parent | 14d7988623d51d9a639a0a8c766a2b3cd279f7a0 (diff) |
fix tree window while moving up down
Diffstat (limited to 'src')
-rw-r--r-- | src/preview.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/preview.rs b/src/preview.rs index da56708..e0554ba 100644 --- a/src/preview.rs +++ b/src/preview.rs @@ -644,19 +644,19 @@ impl Directory { /// is selected and the size of the window used to display. pub fn calculate_tree_window(&self, height: usize) -> (usize, usize, usize) { let length = self.content.len(); - let mut top = if self.selected_index < height { + let mut top = if self.selected_index < height - 1 { 0 } else { - self.selected_index + self.selected_index - 1 }; - let mut bottom = if self.selected_index < height { - height + let mut bottom = if self.selected_index < height - 1 { + height - 1 } else { - self.selected_index + height + self.selected_index + height - 1 }; let padding = std::cmp::max(10, height / 2); - if self.selected_index > height { + if self.selected_index >= height - 1 { top -= padding; bottom += padding; } |