Skip to content

Commit eb9b075

Browse files
author
Stephan Dilly
committed
show scrollbars in tree and syntax text (#725)
1 parent 13b346b commit eb9b075

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/components/revision_files.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,18 @@ impl DrawableComponent for RevisionFilesComponent {
197197
usize::from(chunks[0].height.saturating_sub(2));
198198

199199
let selection = self.tree.visual_selection();
200-
selection.map_or_else(
201-
|| self.scroll_top.set(0),
200+
let visual_count = selection.map_or_else(
201+
|| {
202+
self.scroll_top.set(0);
203+
0
204+
},
202205
|selection| {
203206
self.scroll_top.set(ui::calc_scroll_top(
204207
self.scroll_top.get(),
205208
tree_height,
206209
selection.index,
207-
))
210+
));
211+
selection.count
208212
},
209213
);
210214

@@ -242,6 +246,16 @@ impl DrawableComponent for RevisionFilesComponent {
242246
items,
243247
);
244248

249+
if is_tree_focused {
250+
ui::draw_scrollbar(
251+
f,
252+
chunks[0],
253+
&self.theme,
254+
visual_count.saturating_sub(tree_height),
255+
self.scroll_top.get(),
256+
);
257+
}
258+
245259
self.current_file.draw(f, chunks[1])?;
246260
}
247261

src/components/syntax_text.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ impl DrawableComponent for SyntaxTextComponent {
187187

188188
self.scroll(None);
189189

190+
if self.focused() {
191+
ui::draw_scrollbar(
192+
f,
193+
area,
194+
&self.theme,
195+
usize::from(state.lines().saturating_sub(
196+
state.height().saturating_sub(2),
197+
)),
198+
usize::from(state.scroll().y),
199+
);
200+
}
201+
190202
Ok(())
191203
}
192204
}

0 commit comments

Comments
 (0)