From a97bf79cf79cddfca4453bc8604552a99af1499b Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Sun, 31 Mar 2024 01:51:56 +0530 Subject: [PATCH] Consume all mouse events inside popups Fixes issues of mouse clicks "bleeding" through into the editor when clicked on top of popups. In previous versions, mouse events were ignored and passed into the lower layers which resulted in editor cursor being moved when popup areas are clicked. --- helix-term/src/ui/popup.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/helix-term/src/ui/popup.rs b/helix-term/src/ui/popup.rs index 4c8c1ebd9..93018e08c 100644 --- a/helix-term/src/ui/popup.rs +++ b/helix-term/src/ui/popup.rs @@ -204,14 +204,16 @@ fn handle_mouse_event( match kind { MouseEventKind::ScrollDown if self.has_scrollbar => { self.scroll_half_page_down(); - EventResult::Consumed(None) } MouseEventKind::ScrollUp if self.has_scrollbar => { self.scroll_half_page_up(); - EventResult::Consumed(None) } - _ => EventResult::Ignored(None), - } + _ => {} + }; + + // Mouse event happened within the popup; consume the event so that + // it doesn't bleed into the editor. + EventResult::Consumed(None) } fn close_cb(&self) -> Callback {