mirror of
https://github.com/gitui-org/gitui.git
synced 2026-10-12 02:14:16 +00:00
show scrollbars in tree and syntax text (#725)
This commit is contained in:
@@ -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])?;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user