summaryrefslogtreecommitdiff
path: root/lisp/minibuffer.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-03-27 10:41:06 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-03-27 10:41:06 -0400
commitb1da29572e811d18ee5f200a28192ea2f58ff9bf (patch)
tree2dce39700f324490ddcfb2bd2a11167bc10f82d7 /lisp/minibuffer.el
parentf557c1b1a9b24212728bf27027f0d0cc1d9bbecb (diff)
downloademacs-b1da29572e811d18ee5f200a28192ea2f58ff9bf.tar.gz
* lisp/minibuffer.el (completion-pcm--merge-completions): Make sure prefixes
and suffixes don't overlap. Fixes: debbugs:14061
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r--lisp/minibuffer.el21
1 files changed, 15 insertions, 6 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index ec237f0f664..016b16d0740 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2997,12 +2997,21 @@ the same set of elements."
;; here any more.
(unless unique
(push elem res)
- (when (memq elem '(star point prefix))
- ;; Extract common suffix additionally to common prefix.
- ;; Only do it for `point', `star', and `prefix' since for
- ;; `any' it could lead to a merged completion that
- ;; doesn't itself match the candidates.
- (let ((suffix (completion--common-suffix comps)))
+ ;; Extract common suffix additionally to common prefix.
+ ;; Don't do it for `any' since it could lead to a merged
+ ;; completion that doesn't itself match the candidates.
+ (when (and (memq elem '(star point prefix))
+ ;; If prefix is one of the completions, there's no
+ ;; suffix left to find.
+ (not (assoc-string prefix comps t)))
+ (let ((suffix
+ (completion--common-suffix
+ (if (zerop (length prefix)) comps
+ ;; Ignore the chars in the common prefix, so we
+ ;; don't merge '("abc" "abbc") as "ab*bc".
+ (let ((skip (length prefix)))
+ (mapcar (lambda (str) (substring str skip))
+ comps))))))
(cl-assert (stringp suffix))
(unless (equal suffix "")
(push suffix res)))))