show scrollbars in tree and syntax text (#725)

This commit is contained in:
Stephan Dilly 2021-05-24 01:29:48 +02:00
parent 13b346b8b1
commit eb9b0753a0
2 changed files with 29 additions and 3 deletions

View file

@ -197,14 +197,18 @@ impl DrawableComponent for RevisionFilesComponent {
usize::from(chunks[0].height.saturating_sub(2));
let selection = self.tree.visual_selection();
selection.map_or_else(
|| self.scroll_top.set(0),
let visual_count = selection.map_or_else(
|| {
self.scroll_top.set(0);
0
},
|selection| {
self.scroll_top.set(ui::calc_scroll_top(
self.scroll_top.get(),
tree_height,
selection.index,
))
));
selection.count
},
);
@ -242,6 +246,16 @@ impl DrawableComponent for RevisionFilesComponent {
items,
);
if is_tree_focused {
ui::draw_scrollbar(
f,
chunks[0],
&self.theme,
visual_count.saturating_sub(tree_height),
self.scroll_top.get(),
);
}
self.current_file.draw(f, chunks[1])?;
}

View file

@ -187,6 +187,18 @@ impl DrawableComponent for SyntaxTextComponent {
self.scroll(None);
if self.focused() {
ui::draw_scrollbar(
f,
area,
&self.theme,
usize::from(state.lines().saturating_sub(
state.height().saturating_sub(2),
)),
usize::from(state.scroll().y),
);
}
Ok(())
}
}