on master help sign in
Right align scrollbar with track in completion popup (#2754)
a26943dGokul Soumya
book/src/themes.md+1
@@ -231,6 +231,7 @@ These scopes are used for theming the editor interface.
231| `ui.virtual.indent-guide` | Vertical indent width guides |
231| `ui.virtual.indent-guide` | Vertical indent width guides |
232| `ui.menu` | Code and command completion menus |
232| `ui.menu` | Code and command completion menus |
233| `ui.menu.selected` | Selected autocomplete item |
233| `ui.menu.selected` | Selected autocomplete item |
234+| `ui.menu.scroll` | `fg` sets thumb color, `bg` sets track color of scrollbar |
234| `ui.selection` | For selections in the editing area |
235| `ui.selection` | For selections in the editing area |
235| `ui.selection.primary` | |
236| `ui.selection.primary` | |
236| `warning` | Diagnostics warning (gutter) |
237| `warning` | Diagnostics warning (gutter) |
helix-term/src/ui/menu.rs+19−7
@@ -310,7 +310,7 @@ impl<T: Item + 'static> Component for Menu<T> {
310 use tui::widgets::TableState;
310 use tui::widgets::TableState;
311
311
312 table.render_table(
312 table.render_table(
313− area.clip_left(Self::LEFT_PADDING as u16),
313+ area.clip_left(Self::LEFT_PADDING as u16).clip_right(1),
314 surface,
314 surface,
315 &mut TableState {
315 &mut TableState {
316 offset: scroll,
316 offset: scroll,
@@ -320,20 +320,32 @@ impl<T: Item + 'static> Component for Menu<T> {
320
320
321 if let Some(cursor) = self.cursor {
321 if let Some(cursor) = self.cursor {
322 let offset_from_top = cursor - scroll;
322 let offset_from_top = cursor - scroll;
323− let cell = &mut surface[(area.x, area.y + offset_from_top as u16)];
323+ let left = &mut surface[(area.left(), area.y + offset_from_top as u16)];
324+ left.set_style(selected);
325+ let right = &mut surface[(
326+ area.right().saturating_sub(1),
327+ area.y + offset_from_top as u16,
328+ )];
324− cell.set_style(selected);
329+ right.set_style(selected);
325 }
330 }
326
331
327 let fits = len <= win_height;
332 let fits = len <= win_height;
328
333
334+ let scroll_style = theme.get("ui.menu.scroll");
329 for (i, _) in (scroll..(scroll + win_height).min(len)).enumerate() {
335 for (i, _) in (scroll..(scroll + win_height).min(len)).enumerate() {
336+ let cell = &mut surface[(area.x + area.width - 1, area.y + i as u16)];
337+
338+ if !fits {
339+ // Draw scroll track
340+ cell.set_symbol("▐"); // right half block
341+ cell.set_fg(scroll_style.bg.unwrap_or(helix_view::theme::Color::Reset));
342+ }
343+
330 let is_marked = i >= scroll_line && i < scroll_line + scroll_height;
344 let is_marked = i >= scroll_line && i < scroll_line + scroll_height;
331
345
332 if !fits && is_marked {
346 if !fits && is_marked {
333− let cell = &mut surface[(area.x + area.width - 2, area.y + i as u16)];
347+ // Draw scroll thumb
334− cell.set_symbol("▐");
348+ cell.set_fg(scroll_style.fg.unwrap_or(helix_view::theme::Color::Reset));
335− // cell.set_style(selected);
336− // cell.set_style(if is_marked { selected } else { style });
337 }
349 }
338 }
350 }
339 }
351 }
runtime/themes/onedark.toml+1
@@ -73,6 +73,7 @@ diagnostic = { modifiers = ["underlined"] }
73"ui.window" = { bg = "gray" }
73"ui.window" = { bg = "gray" }
74"ui.menu" = { fg = "white", bg = "gray" }
74"ui.menu" = { fg = "white", bg = "gray" }
75"ui.menu.selected" = { fg = "black", bg = "blue" }
75"ui.menu.selected" = { fg = "black", bg = "blue" }
76+"ui.menu.scroll" = { fg = "white", bg = "light-gray" }
76
77
77[palette]
78[palette]
78
79
theme.toml+1
@@ -69,6 +69,7 @@ label = "honey"
69
69
70"ui.menu" = { fg = "lavender", bg = "revolver" }
70"ui.menu" = { fg = "lavender", bg = "revolver" }
71"ui.menu.selected" = { fg = "revolver", bg = "white" }
71"ui.menu.selected" = { fg = "revolver", bg = "white" }
72+"ui.menu.scroll" = { fg = "lavender", bg = "comet" }
72
73
73diagnostic = { modifiers = ["underlined"] }
74diagnostic = { modifiers = ["underlined"] }
74# "diagnostic.hint" = { fg = "revolver", bg = "lilac" }
75# "diagnostic.hint" = { fg = "revolver", bg = "lilac" }