]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle point not at EOB in minibuffer-choose-completion
authorSpencer Baugh <sbaugh@janestreet.com>
Mon, 24 Apr 2023 14:05:24 +0000 (10:05 -0400)
committerJuri Linkov <juri@linkov.net>
Wed, 14 Jun 2023 17:31:34 +0000 (20:31 +0300)
Without this change, only the minibuffer contents before point are
cleared when a completion is chosen, which results in stray text when
point is in the middle of the minibuffer.

After this change, we heuristically decide either to clear the whole
buffer or only part of it, taking into account the location of point.

* lisp/minibuffer.el (minibuffer-completion-help): Use point when
calculating completion-base-affixes. (Bug#62700)

lisp/minibuffer.el

index 539206a19e46ea3879f89ea04149f3c3d58980b3..d079dc0bcdfcddb57fac19ed82efd4bc5b2cdaf4 100644 (file)
@@ -2395,7 +2395,11 @@ These include:
              (prefix (unless (zerop base-size) (substring string 0 base-size)))
              (base-prefix (buffer-substring (minibuffer--completion-prompt-end)
                                             (+ start base-size)))
-             (base-suffix (buffer-substring (point) (point-max)))
+             (base-suffix
+              (if (eq (alist-get 'category (cdr md)) 'file)
+                  (buffer-substring (save-excursion (or (search-forward "/" nil t) (point-max)))
+                                    (point-max))
+                ""))
              (all-md (completion--metadata (buffer-substring-no-properties
                                             start (point))
                                            base-size md