visual-regexp.el icon indicating copy to clipboard operation
visual-regexp.el copied to clipboard

Display artifacts when deleting pattern

Open codecoll opened this issue 3 years ago • 3 comments

  1. Start vr/query-replace
  2. type one character which matches current buffer contents, e.g: a
  3. delete the character, so the pattern is empty
  4. instead of showing the unchanged buffer, many | characters are shown

codecoll avatar Jan 10 '22 12:01 codecoll

It's not an artefact really, it is all the locations that match. If you hit enter and start typing the replacement, you will see the replacement appear in all those locations.

I disabled rendering these with the initial empty pattern as that would be a bit too distracting imho, as most of the time you want to actually search for a non-empty string.

benma avatar Jan 10 '22 13:01 benma

Highlighting the empty pattern seems unecessary, since if one wants to replace the empty string then one knows it matches after every character, so it does not give any useful information.

Shouldn't it work like the initial empty pattern, so it's consistent? I thought it was a bug, because it added | characters when I deleted the pattern which I didn't understand, since the user expects that by deleting the pattern one gets back to the inital state.

codecoll avatar Jan 10 '22 14:01 codecoll

since if one wants to replace the empty string then one knows it matches after every character

Same could be said for any other pattern, but this package is here to give visual feedback on your pattern. Explicit is better than implicit.

Shouldn't it work like the initial empty pattern, so it's consistent?

It could, but this is why I wrote:

I disabled rendering these with the initial empty pattern as that would be a bit too distracting imho, as most of the time you want to actually search for a non-empty string.

It is inconsistent though for sure.

I don't have a very strong opinion. Feel free to open a PR if you think it's worth it (but only for the empty pattern, there can be other zero-width patterns that should still be rendered).

benma avatar Jan 10 '22 15:01 benma