From: Eshel Yaron Date: Mon, 22 Jan 2024 16:49:58 +0000 (+0100) Subject: ; Fix bounds check in 'minibuffer-restore-completion-input' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b221de7caadd872c6a51bec96cb4d97787a43567;p=emacs.git ; Fix bounds check in 'minibuffer-restore-completion-input' * lisp/minibuffer.el (minibuffer-force-complete): Don't count the length of the input-to-restore when checking the bounds of the current minibuffer contents. Also, refresh the *Completions* buffer if it is already visible. --- diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 01d1d97e43e..b6febca4d6a 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1983,12 +1983,15 @@ Interactively, ARG is the prefix argument, and it defaults to 1." (base-size (length base)) (prompt-end (minibuffer-prompt-end))) (setq completion--input nil) - (if (and string (<= (+ prompt-end base-size (length string)) (point-max)) - ;; Don't restore if the base has changed. - (equal base (buffer-substring-no-properties - prompt-end (+ prompt-end base-size)))) - (completion--replace (+ prompt-end base-size) (point-max) string) - (user-error "No partial completion input to restore")))) + (unless (and string (<= (+ prompt-end base-size) (point-max)) + ;; Don't restore if the base part has changed. + (equal base (buffer-substring-no-properties + prompt-end (+ prompt-end base-size)))) + (user-error "No partial completion input to restore")) + (completion--replace (+ prompt-end base-size) (point-max) string) + (when (get-buffer-window "*Completions*" 0) + ;; Refresh *Completions* buffer, if already visible. + (minibuffer-completion-help)))) (defun minibuffer-force-complete (&optional start end dont-cycle) "Complete the minibuffer to an exact match.