-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
case-folding behavior of anzu-isearch-query-replace
#103
Comments
hello @syohex, do you have any insights on these case-sensitivity bugs? |
I'm not sure, I never use diff --git a/anzu.el b/anzu.el
index d51727b..cce7de7 100644
--- a/anzu.el
+++ b/anzu.el
@@ -163,10 +163,12 @@
(defsubst anzu--construct-position-info (count overflow positions)
(list :count count :overflow overflow :positions positions))
-(defsubst anzu--case-fold-search ()
+(defsubst anzu--case-fold-search (input)
(if isearch-mode
isearch-case-fold-search
- case-fold-search))
+ (when case-fold-search
+ (let ((case-fold-search nil))
+ (not (string-match-p "[A-Z]" input))))))
(defsubst anzu--word-search-p ()
(and (not (memq anzu--last-command anzu-regexp-search-commands))
@@ -206,7 +208,7 @@
(with-no-warnings
(migemo-forward word bound noerror count)))
#'re-search-forward))
- (case-fold-search (anzu--case-fold-search)))
+ (case-fold-search (anzu--case-fold-search input)))
(while (and (not finish) (funcall search-func input nil t))
(push (cons (match-beginning 0) (match-end 0)) positions)
(cl-incf count)
@@ -399,7 +401,7 @@
(step (if backward -1 1))
(case-fold-search (if case-sensitive
nil
- (anzu--case-fold-search))))
+ (anzu--case-fold-search str))))
(while (and (not finish) (funcall search-func str replace-end t))
(cl-incf count)
(let ((beg (match-beginning 0)) |
Agree. I have a very similar set of diffs sitting in here on my laptop ... but as I recall, making that change caused other cases to be broken, so I never checked in the changes. |
Imagine the user does an
isearch-forward
and toggles a case sensitive search withM-c
. The subsequentanzu-isearch-query-replace
should not only search for the prior search string, but it should also use the case-sensitivity specified in the prior search. That's not the case.Example. The buffer contains
Searching for "anzu" will match all three words. Searching for "Anzu" will match just the middle word. Searching for "anzu" with
M-c
will match the first and last word.However, after a case-sensitive (
M-c
) search with the string "anzu", the subsequentanzu-isearch-query-replace
will always ask to replace all three words. This is the case that needs to be fixed, because theM-c
should be honored in the query-replace.The text was updated successfully, but these errors were encountered: