Vim icon indicating copy to clipboard operation
Vim copied to clipboard

`:%s` does not highlight in editor when using capture groups.

Open sirno opened this issue 3 years ago • 2 comments

Describe the bug

When using \( and \) to indicate a group, the matches will not be highlighted in editor.

To Reproduce

For

a = "foo"
b = "@foo"

the pattern :%s/"\(@*\)foo"/"\1baz"\g, will correctly sustitute to

a = "baz"
b = "@baz"

however the changes will not be previewed in editor.

The pattern :%s/"(@*)foo"/"\1baz"\g, will indicate the changes in editor, but produce a pattern not found error when executed.

Expected behavior

  • :%s/"\(@*\)foo"/"\1baz"\g should match in the editor.
  • :%s/"(@*)foo"/"\1baz"\g should not match in the editor.

Environment (please complete the following information):

Extension version: 1.23.2 VS Code version: Code - Insiders 1.72.0-insider (1a55beb2aaee64eb8d0cbe5b61b10088bbc6c895, 2022-09-13T05:32:07.204Z) OS version: Darwin arm64 21.6.0 Modes: Sandboxed: Yes

sirno avatar Sep 14 '22 08:09 sirno

I think this is related to #3996

sirno avatar Sep 14 '22 09:09 sirno

This only happens when "vim.enableNeovim" = true and is related to which characters are considered special (aka the magicness) and which need to be escaped.

I guess either way having two different engines parsing the same regex is asking for trouble 🎉 I implemented a quick dirty fix that flips (, ) and \\(, \\), but will not pr unless there is serious interest, because it would change the behavior of grouping when neovim is disabled.

sirno avatar Sep 14 '22 12:09 sirno