Skip to content
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

"Replace All" with $ replacement sometimes gets the replacement wrong #942

Open
5 tasks done
danfuzz opened this issue Mar 4, 2024 · 1 comment
Open
5 tasks done
Labels
bug Something isn't working

Comments

@danfuzz
Copy link
Contributor

danfuzz commented Mar 4, 2024

Thanks in advance for your bug report!

  • Have you reproduced issue in safe mode?
  • Have you used the debugging guide to try to resolve the issue?
  • Have you checked our FAQs to make sure your question isn't answered there?
  • Have you checked to make sure your issue does not already exist?
  • 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?

  1. Have some files in a project with contents that are amenable to a match group replacement.
  2. "Find All."
  3. Write a pattern to find like prefix(Option1|Option2).
  4. Write a replacement like newPrefix$1.
  5. Find all!
  6. 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.

@Digitalone1
Copy link
Contributor

Digitalone1 commented May 16, 2024

I tried to reproduce this issue and maybe I found a workaround.

First, write the pattern without capturing groups:

Schermata del 2024-05-16 09-06-21

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:

Schermata del 2024-05-16 09-07-55

To workaround this issue, just restart the search clicking on Find all. Now the previews are correct.

Schermata del 2024-05-16 09-08-11

Replace All and it works:

Schermata del 2024-05-16 09-09-04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants