Only disable 'completion-preview-active-mode' when it is on

* lisp/completion-preview.el
(completion-preview--post-command): Avoid calling
'completion-preview-active-mode' to disable the mode when
already off, since it forces a costly redisplay. (Bug#76964)
This commit is contained in:
Eshel Yaron 2025-03-16 09:45:25 +01:00
parent 91a9d02199
commit b6b4a080a3
No known key found for this signature in database
GPG key ID: EF3EE9CA35D78618

View file

@ -437,13 +437,17 @@ point, otherwise hide it."
(cancel-timer completion-preview--timer)
(setq completion-preview--timer nil))
;; If we're called after a command that itself updates the
;; preview, don't do anything.
(unless internal-p
(if (and (completion-preview-require-certain-commands)
(completion-preview-require-minimum-symbol-length))
(completion-preview--show)
(completion-preview-active-mode -1)))))
(cond
(internal-p
;; `this-command' took care of updating the preview. Do nothing.
)
((and (completion-preview-require-certain-commands)
(completion-preview-require-minimum-symbol-length))
;; All conditions met. Show or update the preview.
(completion-preview--show))
(completion-preview-active-mode
;; The preview is shown, but it shouldn't be. Hide it.
(completion-preview-active-mode -1)))))
(defun completion-preview-insert ()
"Insert the completion candidate that the preview is showing."