mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Don't resort Icomplete candidates when default already on top
Fixes: bug#43222 Icomplete mode re-sorts candidates, bubbling the default to top if it's found somewhere down the list. This is done according to two criteria: exact match and prefix match. Before this fix, it didn't take into account the possibility that the exact match for the default would already be on top, and would incorrectly bubble a prefixing completion down the list to the top. This commit fixes that. * lisp/icomplete.el (icomplete--sorted-completions): Rework. Recomment.
This commit is contained in:
parent
669b46e6a3
commit
6fc502c1ef
1 changed files with 13 additions and 8 deletions
|
|
@ -469,6 +469,7 @@ Usually run by inclusion in `minibuffer-setup-hook'."
|
|||
with beg = (icomplete--field-beg)
|
||||
with end = (icomplete--field-end)
|
||||
with all = (completion-all-sorted-completions beg end)
|
||||
;; First, establish the "bubble up" predicates.
|
||||
for fn in (cond ((and minibuffer-default
|
||||
(stringp minibuffer-default) ; bug#38992
|
||||
(= (icomplete--field-end) (icomplete--field-beg)))
|
||||
|
|
@ -493,14 +494,18 @@ Usually run by inclusion in `minibuffer-setup-hook'."
|
|||
;; what vanilla Emacs and `ido-mode' both do.
|
||||
`(,(lambda (comp)
|
||||
(string= "./" comp)))))
|
||||
thereis (cl-loop
|
||||
for l on all
|
||||
while (consp (cdr l))
|
||||
for comp = (cadr l)
|
||||
when (funcall fn comp)
|
||||
do (setf (cdr l) (cddr l))
|
||||
and return
|
||||
(completion--cache-all-sorted-completions beg end (cons comp all)))
|
||||
;; Now, look for a completion matching one of those predicates
|
||||
;; to bubble up (unless that completion is already on top).
|
||||
thereis (or
|
||||
(and (funcall fn (car all)) all)
|
||||
(cl-loop
|
||||
for l on all
|
||||
while (consp (cdr l))
|
||||
for comp = (cadr l)
|
||||
when (funcall fn comp)
|
||||
do (setf (cdr l) (cddr l))
|
||||
and return
|
||||
(completion--cache-all-sorted-completions beg end (cons comp all))))
|
||||
finally return all)))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue