Commit 639fb50e authored by João Távora's avatar João Távora

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.
parent 13778aa5
Pipeline #4398 failed with stage
in 54 minutes
......@@ -442,36 +442,37 @@ Usually run by inclusion in `minibuffer-setup-hook'."
(add-hook 'post-command-hook 'icomplete-post-command-hook nil t)))
(defun icomplete--sorted-completions ()
(cl-loop
with beg = (icomplete--field-beg)
with end = (icomplete--field-end)
with all = (completion-all-sorted-completions beg end)
for fn in (cond ((and minibuffer-default
(= (icomplete--field-end) (icomplete--field-beg)))
;; When we have a non-nil default and no input
;; whatsoever: we want to make sure that default
;; is bubbled to the top so that
;; `icomplete-force-complete-and-exit' will
;; select it (do that even if the match doesn't
;; match the completion perfectly.
`(,(lambda (comp)
(equal minibuffer-default comp))
,(lambda (comp)
(string-prefix-p minibuffer-default comp))))
((and fido-mode
(not minibuffer-default)
(eq (icomplete--category) 'file))
`(,(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)))
finally return all))
(or completion-all-sorted-completions
(cl-loop
with beg = (icomplete--field-beg)
with end = (icomplete--field-end)
with all = (completion-all-sorted-completions beg end)
for fn in (cond ((and minibuffer-default
(= (icomplete--field-end) (icomplete--field-beg)))
;; When we have a non-nil default and no input
;; whatsoever: we want to make sure that default
;; is bubbled to the top so that
;; `icomplete-force-complete-and-exit' will
;; select it (do that even if the match doesn't
;; match the completion perfectly.
`(,(lambda (comp)
(equal minibuffer-default comp))
,(lambda (comp)
(string-prefix-p minibuffer-default comp))))
((and fido-mode
(not minibuffer-default)
(eq (icomplete--category) 'file))
`(,(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)))
finally return all)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment