pulsar
pulsar copied to clipboard
"Replace All" with `$` replacement sometimes gets the replacement wrong
Thanks in advance for your bug report!
- [X] Have you reproduced issue in safe mode?
- [X] Have you used the debugging guide to try to resolve the issue?
- [X] Have you checked our FAQs to make sure your question isn't answered there?
- [X] Have you checked to make sure your issue does not already exist?
- [X] Have you checked you are on the latest release of Pulsar?
What happened?
"Replace all" with match group replacement ($N) sometimes uses the wrong matching string. I'm not entirely sure what triggers it, and, for example, I'll sometimes see that within a single "replace all" action, some replacements will be right and some will be wrong.
For example, I recently tried to replace \b_impl_serverSocket(Start|Stop)\b with _impl_socket$1 using "replace all." Of the three files that were affected, one was correct, and the other two had diffs like this:
// the application might need to see the server stopping _and_ vice versa.
await Promise.all([
- this._impl_serverSocketStop(this.#reloading),
+ this._impl_socketStart(this.#reloading),
this._impl_applicationStop(this.#reloading)
Pulsar version
1.114.0
Which OS does this happen on?
🍎 macOS
OS details
13.6.3
Which CPU architecture are you running this on?
ARM64/AArch64
What steps are needed to reproduce this?
- Have some files in a project with contents that are amenable to a match group replacement.
- "Find All."
- Write a pattern to find like
prefix(Option1|Option2). - Write a replacement like
newPrefix$1. - Find all!
- Replace all!
Note that some of the replacements are wrong.
Additional Information:
When you look at the preview for replacements in these cases (in the search results window), the preview looks correct.
I tried to reproduce this issue and maybe I found a workaround.
First, write the pattern without capturing groups:
Start the search in project. You should see all the results. Then add the capturing group and type the replacement. The group is not replaced correctly, indeed $1 is shown in the preview:
To workaround this issue, just restart the search clicking on Find all. Now the previews are correct.
Replace All and it works: