oantolin / orderless

Emacs completion style that matches multiple regexps in any order

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

orderless-try-completion should return t for single match

minad opened this issue · comments

Orderless returns a cons of string and the point position. It would be correct to return t if the match is exact and this is what basic, substring and flex seem to return. I rely on this behavior in Corfu to check if further completion is possible: https://github.com/minad/corfu/blob/845586319da7e9361c672c87a9fd73f0b069376b/corfu.el#L760-L764.

Wrong:

(orderless-try-completion "test" '("test" "foo" "bar") nil 0) ;; ("test" . 4)
(orderless-try-completion "test" '("test" "foo" "bar") nil 4) ;; ("test" . 4)
(completion-substring-try-completion "test" '("test" "foo" "bar") nil 0) ;; t
(completion-substring-try-completion "test" '("test" "foo" "bar") nil 4) ;; t

Correct:

(orderless-try-completion "es" '("test" "foo" "bar") nil 0) ;; ("test" . 4)
(orderless-try-completion "es" '("test" "foo" "bar") nil 2) ;; ("test" . 4)
(completion-substring-try-completion "es" '("test" "foo" "bar") nil 0) ;; ("test" . 4)
(completion-substring-try-completion "es" '("test" "foo" "bar") nil 2) ;; ("test" . 4)

Whoops! Thanks for catching this!

Thanks for the quick fix!