Fix c-pcm-try-completion with boundaries completion

PCM try-completion could behavior incorrectly with completion
tables using boundaries, such as file name completion.  It would
"grow" earlier path components as if point was at the end of
each path component (rather than at its true location), which
meant all path components would "grow" not only from the left
\(which is correct) but also from the right (which can only work
when point is there).

* lisp/minibuffer.el (completion-pcm--find-all-completions):
Drop the sub-pattern's trailing `point' (bug#80914).
* test/lisp/minibuffer-tests.el (completion-pcm-test-9): New
test.
This commit is contained in:
Spencer Baugh 2026-06-29 17:30:01 -04:00 committed by Sean Whitton
parent e560eacf6d
commit 6b31360a31
4 changed files with 20 additions and 0 deletions

View file

@ -4608,6 +4608,11 @@ filter out additional entries (because TABLE might not obey PRED)."
;; Text that goes between the new submatches and the
;; completion substring.
(between nil))
;; SUBPAT was computed with point=(length substring); remove
;; the trailing `point' since that's not the real location of
;; point (bug#80914).
(cl-assert (eq (car (last subpat)) 'point))
(setq subpat (butlast subpat))
;; Eliminate submatches that don't end with the separator.
(dolist (submatch (prog1 suball (setq suball ())))
(when (eq sep (aref submatch (1- (length submatch))))

View file

@ -340,6 +340,21 @@
"" '("fooxbar" "fooybar") nil 0)
'("foobar" . 3))))
(ert-deftest completion-pcm-bug80914 ()
;; Completing a partial match in an earlier component (here "s"
;; matches both "sys" and "sources", which contain "class" and
;; "clang") should not leave a stray `point' in the middle of the
;; merged pattern (bug#80914).
(let ((default-directory (ert-resource-directory))
(input "pcm/s/cl"))
;; The pattern has a single `point' at the end rather than an extra
;; `point' after the "s".
(should (equal (completion-pcm--find-all-completions
input #'completion--file-name-table nil (length input))
'(("s" any "/" "cl" point)
("sources/clang" "sys/class")
"pcm/" "")))))
(ert-deftest completion-pcm-test-anydelim ()
;; After each delimiter is a special wildcard which matches any
;; sequence of delimiters.