|
From: | Dmitry Gutov |
Subject: | bug#67650: [PATCH] ; Hide completion preview when switching windows |
Date: | Wed, 6 Dec 2023 22:02:25 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
This patch ensures that we dismiss the completion preview when users switch to another window. Previously, the completion preview would remain in a window after switching to another window showing another buffer, since the `post-command-hook` that Completion Preview mode sets up locally doesn't run after a command switches to another buffer.
Another way to do this would look like this: diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 1d5f1253702..f2560a98b23 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -182,6 +182,7 @@ completion-preview--make-overlay (eq (get-text-property 0 'face previous) (get-text-property 0 'face string))) (add-text-properties 0 1 '(cursor 1) string) + (overlay-put completion-preview--overlay 'window (selected-window)) (overlay-put completion-preview--overlay 'after-string string)) completion-preview--overlay))Although it depends on whether the overlay itself staying around is a good thing for this feature.
You could also move some cleanup logic to pre-command-hook, which should be fine with the buffer-locality of the value.
[Prev in Thread] | Current Thread | [Next in Thread] |