fix(vertico): orderless filtering
The original implementation of `+vertico-orderless-dispatch` match
pattern by prefix and suffix in pairs. In that case, '=&&' will go for
branch `(string-suffix-p "&" pattern)`, not `(string-prefix-p "="
pattern)`, which fail to filter literal '&&'.
We probably should match all prefixes first, then all suffixes. Just
like orderless does.
Ref: 178b0c55f2/orderless.el (L159)
This commit is contained in:
parent
db48f767b0
commit
3ad8ecc063
1 changed files with 13 additions and 21 deletions
|
@ -74,30 +74,23 @@ orderless."
|
|||
(completion-styles +vertico-company-completion-styles))
|
||||
(apply fn args)))
|
||||
|
||||
(setq orderless-affix-dispatch-alist
|
||||
`((?! . ,#'orderless-without-literal)
|
||||
(?& . ,#'orderless-annotation)
|
||||
(?% . ,#'char-fold-to-regexp)
|
||||
(?` . ,#'orderless-initialism)
|
||||
(?= . ,#'orderless-literal)
|
||||
(?^ . ,#'orderless-literal-prefix)
|
||||
(?~ . ,#'orderless-flex)))
|
||||
|
||||
(defun +vertico-orderless-dispatch (pattern _index _total)
|
||||
(cond
|
||||
;; Ensure $ works with Consult commands, which add disambiguation suffixes
|
||||
((string-suffix-p "$" pattern)
|
||||
`(orderless-regexp . ,(concat (substring pattern 0 -1) "[\x200000-\x300000]*$")))
|
||||
;; Ignore single !
|
||||
((string= "!" pattern) `(orderless-literal . ""))
|
||||
;; Without literal
|
||||
((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1)))
|
||||
;; Annotation
|
||||
((string-prefix-p "&" pattern) `(orderless-annotation . ,(substring pattern 1)))
|
||||
((string-suffix-p "&" pattern) `(orderless-annotation . ,(substring pattern 0 -1)))
|
||||
;; Character folding
|
||||
((string-prefix-p "%" pattern) `(char-fold-to-regexp . ,(substring pattern 1)))
|
||||
((string-suffix-p "%" pattern) `(char-fold-to-regexp . ,(substring pattern 0 -1)))
|
||||
;; Initialism matching
|
||||
((string-prefix-p "`" pattern) `(orderless-initialism . ,(substring pattern 1)))
|
||||
((string-suffix-p "`" pattern) `(orderless-initialism . ,(substring pattern 0 -1)))
|
||||
;; Literal matching
|
||||
((string-prefix-p "=" pattern) `(orderless-literal . ,(substring pattern 1)))
|
||||
((string-suffix-p "=" pattern) `(orderless-literal . ,(substring pattern 0 -1)))
|
||||
;; Flex matching
|
||||
((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1)))
|
||||
((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1)))))
|
||||
`(orderless-regexp . ,(concat (substring pattern 0 -1) "[\x200000-\x300000]*$")))))
|
||||
|
||||
(add-to-list 'orderless-style-dispatchers '+vertico-orderless-dispatch)
|
||||
|
||||
(add-to-list
|
||||
'completion-styles-alist
|
||||
'(+vertico-basic-remote
|
||||
|
@ -109,7 +102,6 @@ orderless."
|
|||
;; note that despite override in the name orderless can still be used in
|
||||
;; find-file etc.
|
||||
completion-category-overrides '((file (styles +vertico-basic-remote orderless partial-completion)))
|
||||
orderless-style-dispatchers '(+vertico-orderless-dispatch)
|
||||
orderless-component-separator #'orderless-escapable-split-on-space)
|
||||
;; ...otherwise find-file gets different highlighting than other commands
|
||||
(set-face-attribute 'completions-first-difference nil :inherit nil))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue