patch 9.1.1305: completion menu active after switching windows/tabs
Problem: When switching to another window or tab page while the
completion menu is active, the menu stays visible, although it
belongs to the previous window/tab page context (Evgeni
Chasnovski).
Solution: Track the window and tab page where completion started. Detect
changes in the main editing loop and cancel completion mode if
the current window or tab page differs from where completion
started.
fixes: #17090
closes: #17101
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/edit.c b/src/edit.c
index ab67fdc..3c98bb8 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1411,6 +1411,11 @@
)
did_cursorhold = FALSE;
+ // Check if we need to cancel completion mode because the window
+ // or tab page was changed
+ if (ins_compl_active() && !ins_compl_win_active(curwin))
+ ins_compl_cancel();
+
// If the cursor was moved we didn't just insert a space
if (arrow_used)
inserted_space = FALSE;