Skip to content

Commit 195bde9

Browse files
committed
Don't always resort in recently introduced icomplete--sorted-completions
Doing so breaks icomplete-forward-completions and icomplete-backward-completions. * lisp/icomplete.el (icomplete--sorted-completions): Don't always resort. (cherry picked from commit 639fb50)
1 parent f2a349b commit 195bde9

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

lisp/icomplete.el

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -442,36 +442,37 @@ Usually run by inclusion in `minibuffer-setup-hook'."
442442
(add-hook 'post-command-hook 'icomplete-post-command-hook nil t)))
443443

444444
(defun icomplete--sorted-completions ()
445-
(cl-loop
446-
with beg = (icomplete--field-beg)
447-
with end = (icomplete--field-end)
448-
with all = (completion-all-sorted-completions beg end)
449-
for fn in (cond ((and minibuffer-default
450-
(= (icomplete--field-end) (icomplete--field-beg)))
451-
;; When we have a non-nil default and no input
452-
;; whatsoever: we want to make sure that default
453-
;; is bubbled to the top so that
454-
;; `icomplete-force-complete-and-exit' will
455-
;; select it (do that even if the match doesn't
456-
;; match the completion perfectly.
457-
`(,(lambda (comp)
458-
(equal minibuffer-default comp))
459-
,(lambda (comp)
460-
(string-prefix-p minibuffer-default comp))))
461-
((and fido-mode
462-
(not minibuffer-default)
463-
(eq (icomplete--category) 'file))
464-
`(,(lambda (comp)
465-
(string= "./" comp)))))
466-
thereis (cl-loop
467-
for l on all
468-
while (consp (cdr l))
469-
for comp = (cadr l)
470-
when (funcall fn comp)
471-
do (setf (cdr l) (cddr l))
472-
and return
473-
(completion--cache-all-sorted-completions beg end (cons comp all)))
474-
finally return all))
445+
(or completion-all-sorted-completions
446+
(cl-loop
447+
with beg = (icomplete--field-beg)
448+
with end = (icomplete--field-end)
449+
with all = (completion-all-sorted-completions beg end)
450+
for fn in (cond ((and minibuffer-default
451+
(= (icomplete--field-end) (icomplete--field-beg)))
452+
;; When we have a non-nil default and no input
453+
;; whatsoever: we want to make sure that default
454+
;; is bubbled to the top so that
455+
;; `icomplete-force-complete-and-exit' will
456+
;; select it (do that even if the match doesn't
457+
;; match the completion perfectly.
458+
`(,(lambda (comp)
459+
(equal minibuffer-default comp))
460+
,(lambda (comp)
461+
(string-prefix-p minibuffer-default comp))))
462+
((and fido-mode
463+
(not minibuffer-default)
464+
(eq (icomplete--category) 'file))
465+
`(,(lambda (comp)
466+
(string= "./" comp)))))
467+
thereis (cl-loop
468+
for l on all
469+
while (consp (cdr l))
470+
for comp = (cadr l)
471+
when (funcall fn comp)
472+
do (setf (cdr l) (cddr l))
473+
and return
474+
(completion--cache-all-sorted-completions beg end (cons comp all)))
475+
finally return all)))
475476

476477

477478

0 commit comments

Comments
 (0)