From 91a7f58986555f1a470371efde4ba432c2fa54de Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 29 Aug 2023 11:39:16 +1000 Subject: [PATCH] autospell: cancel old menu before opening a new one. If the previous spell-fix menu is still open when a new one is opened, close the old one. Signed-off-by: NeilBrown --- python/lib-autospell.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/lib-autospell.py b/python/lib-autospell.py index 33590d0f..6bb5287b 100644 --- a/python/lib-autospell.py +++ b/python/lib-autospell.py @@ -202,6 +202,7 @@ class autospell_view(edlib.Pane): # visible region self.vstart = None self.vend = None + self.menu = None self.call("doc:request:spell:recheck") self.call("doc:request:doc:replaced") # trigger render-lines refresh notification @@ -232,6 +233,8 @@ class autospell_view(edlib.Pane): def handle_click(self, key, focus, mark, xy, str1, **a): "handle:autospell-menu" + if self.menu: + self.menu.call("Cancel") mp = self.call("attach-menu", "", "autospell-choice", xy, ret='pane') self.wordend = mark.dup() st = mark.dup() @@ -245,6 +248,13 @@ class autospell_view(edlib.Pane): self.add_notify(mp, "Notify:Close") return 1 + def handle_notify_close(self, key, focus, **a): + "handle:Notify:Close" + if focus == self.menu: + self.menu = None + return 1 + return edlib.Efallthrough + def handle_choice(self, key, focus, mark, str1, **a): "handle:autospell-choice" if not str1: -- 2.39.5