anzu icon indicating copy to clipboard operation
anzu copied to clipboard

anzu-query-replace: counter can be wrong when using suggested query/replace criteria

Open gonewest818 opened this issue 4 years ago • 0 comments

As reported in #93.

With case-fold-search set to t in a buffer containing:

Gee AB ab AB ab AB ab.

Do, in sequence,

  1. anzu-query-replace e RET RET -- the counter is (1/2) -- quit and go back at the bol (C-a), then
  2. anzu-query-replace ab RET RET -- the counter is (1/6) -- C-a, then
  3. anzu-query-replace RET (accepting the proposed replacement ab → ); the counter wrongly shows (1/2).

This last bug has proved rather hard to reproduce consistently. If I run all the other tests, including those with case-fold-search set to nil, then set case-fold-search to t again and run this one, at point 3 the counter becomes (1/6) instead of (1/2). If you can't reproduce point 3, do another replacement of "e", quit and do an additional one using the suggested replacement, I get (1/6) instead of (1/2) sometimes. The heart of the matter is that sometimes Anzu appears to use the previous replacement's count when performing another one using the suggested completion.

Additionally, with case-fold-search set to nil in the same buffer:

  1. anzu-query-replace "ab" with "cd": offers to replace each "ab" with "cd" , counts correctly to 3 matches; HOWEVER a second anzu-query-replace and accepting the default criteria (ab → cd) results in an incorrect count of 6 matches.

  2. anzu-query-replace "AB" with "CD": offers to replace each "AB" with "CD", counts correctly to 3 matches; again repeating the same query replace with default arguments results in an incorrect count of 6 matches.

gonewest818 avatar Mar 31 '20 21:03 gonewest818