summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Antolín <omar.antolin@gmail.com>2022-11-13 11:19:19 -0600
committerOmar Antolín <omar.antolin@gmail.com>2022-11-13 11:19:19 -0600
commit2debd96da6f75703ccbca6d852ad994ce84fa529 (patch)
tree45f8f07bc1c5ba638bb93292237606985c0bd08e
parentb355ef6d386134f16eafe17051e9fafcfbea9cad (diff)
Correct case-folding when highlighting matches (fix #127)
Highlighting of matches should be done with the same case-folding that filtering is done with! This is perhaps most noticeable with orderless-smart-case on, but was previously incorrect with it off since filtering used completion-ignore-case and highlighting used case-fold-search!
-rw-r--r--orderless.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/orderless.el b/orderless.el
index c6c6450..47e3c99 100644
--- a/orderless.el
+++ b/orderless.el
@@ -249,16 +249,21 @@ at a word boundary in the candidate. This is similar to the
string)
(defun orderless-highlight-matches (regexps strings)
- "Highlight a match of each of the REGEXPS in each of the STRINGS.
+ "Highlight a match of each of the REGEXPS in each of the STRINGS.
Warning: only use this if you know all REGEXPs match all STRINGS!
For the user's convenience, if REGEXPS is a string, it is
converted to a list of regexps according to the value of
`orderless-matching-styles'."
- (when (stringp regexps)
- (setq regexps (orderless-pattern-compiler regexps)))
+ (when (stringp regexps)
+ (setq regexps (orderless-pattern-compiler regexps)))
+ (let ((case-fold-search
+ (if orderless-smart-case
+ (cl-loop for regexp in regexps
+ always (isearch-no-upper-case-p regexp t))
+ completion-ignore-case)))
(cl-loop for original in strings
for string = (copy-sequence original)
- collect (orderless--highlight regexps string)))
+ collect (orderless--highlight regexps string))))
;;; Compiling patterns to lists of regexps