From b308110f22e0cf5c79533b05992801d8159a8d4d Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Fri, 17 Oct 2025 10:07:42 +0200 Subject: [PATCH] Avoid publishing on all mouse events --- src/terminal_box.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index f3a72ff..f27749e 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -1100,10 +1100,12 @@ where } // Update context menu state if let Some(on_context_menu) = &self.on_context_menu { - shell.publish((on_context_menu)(match self.context_menu { - Some(_) => None, - None => match button { - Button::Right => { + match self.context_menu { + Some(_) => { + shell.publish(on_context_menu(None)); + } + None => { + if button == Button::Right { let x = p.x - self.padding.left; let y = p.y - self.padding.top; //TODO: better calculation of position @@ -1120,14 +1122,13 @@ where None, ); let link = get_hyperlink(&terminal, location); - Some(MenuState { + shell.publish(on_context_menu(Some(MenuState { position: Some(p), link, - }) + }))); } - _ => None, - }, - })); + } + } } status = Status::Captured; }