]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix bounds check in 'minibuffer-restore-completion-input'
authorEshel Yaron <me@eshelyaron.com>
Mon, 22 Jan 2024 16:49:58 +0000 (17:49 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 22 Jan 2024 16:49:58 +0000 (17:49 +0100)
* 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.

lisp/minibuffer.el

index 01d1d97e43e5b70319afee98ef57b6704263aaed..b6febca4d6a17a5f467b422a3cf995d36c4dd436 100644 (file)
@@ -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.