From 00520a942b0fd8c3315a754f007952c32d0a19d8 Mon Sep 17 00:00:00 2001 From: Joshua Lin Date: Thu, 1 Feb 2024 23:38:54 -0800 Subject: [PATCH] Fix rendering of popup scrollbar --- helix-term/src/ui/menu.rs | 11 ++++++++--- helix-term/src/ui/popup.rs | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index 64127e3af8b3..67349051ae60 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -419,14 +419,19 @@ impl Component for Menu { for i in 0..win_height { cell = &mut surface[(area.right() - 1, area.top() + i as u16)]; - let half_block = if render_borders { "▌" } else { "▐" }; + let (scroll_thumb, scroll_track) = if render_borders { + ("▌", "│") + } else { + ("▐", "▐") + }; if scroll_line <= i && i < scroll_line + scroll_height { // Draw scroll thumb - cell.set_symbol(half_block); + cell.set_symbol(scroll_thumb); cell.set_fg(scroll_style.fg.unwrap_or(helix_view::theme::Color::Reset)); - } else if !render_borders { + } else { // Draw scroll track + cell.set_symbol(scroll_track); cell.set_fg(scroll_style.bg.unwrap_or(helix_view::theme::Color::Reset)); } } diff --git a/helix-term/src/ui/popup.rs b/helix-term/src/ui/popup.rs index 7a6ffe9dd6d2..7e0bbf945d1a 100644 --- a/helix-term/src/ui/popup.rs +++ b/helix-term/src/ui/popup.rs @@ -295,14 +295,19 @@ impl Component for Popup { for i in 0..win_height { cell = &mut surface[(inner.right() - 1, inner.top() + (border + i) as u16)]; - let half_block = if render_borders { "▌" } else { "▐" }; + let (scroll_thumb, scroll_track) = if render_borders { + ("▌", "│") + } else { + ("▐", "▐") + }; if scroll_line <= i && i < scroll_line + scroll_height { // Draw scroll thumb - cell.set_symbol(half_block); + cell.set_symbol(scroll_thumb); cell.set_fg(scroll_style.fg.unwrap_or(helix_view::theme::Color::Reset)); - } else if !render_borders { + } else { // Draw scroll track + cell.set_symbol(scroll_track); cell.set_fg(scroll_style.bg.unwrap_or(helix_view::theme::Color::Reset)); } }