-
Notifications
You must be signed in to change notification settings - Fork 0
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
[CLOSED] Fixing issue with double dollars in replace string #5348
Comments
Comment by njx Hey--don't have time right now to fully think through/test this, but a couple of notes:
|
Comment by njx BTW, here's a useful reference for the JS behavior: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace - under "Specifying a string as a parameter". (This made me think...Instead of doing our own replacement function, would it make more sense to just use the actual JS replace function, calling it on the previously matched string, passing it the regexp and the user's substitution string? That way we wouldn't have to write all this logic to simulate the JS behavior--we would just get it for free. The precede/follow substitutions wouldn't work, but we haven't implemented those anyway.) |
Comment by MarcelGerber
I don't know how you want to pass matches to the js replace function, but I won't say anything against. |
Comment by MarcelGerber Sorry, not the right commit name ;) It should be |
Comment by MarcelGerber Just added unit tests, so this PR is completely (in my view). |
Comment by MarcelGerber
|
Comment by njx Finished re-review. Looks good, just a few nits. It seems like it would be good to add at least one Replace All case (I probably should have done this when I added the original one)...although that's more complex since you'd have to mock clicking the button in the Replace All panel (or add an API to directly invoke the replace all function). If you feel like looking into that, that would be great, but if not I think it's fine to just do some basic manual testing around it since it's pretty clear now that the behavior in all the edge cases will be consistent. Longer term, when we rewrite the find/replace stuff (which hopefully won't be too long from now), we'll be refactoroing out the actual editing code from the UI, so these can become true unit tests instead of interacting with UI elements. |
Comment by njx BTW, the other idea I mentioned (about just using |
Comment by MarcelGerber Just pushed fixes for these nits. I will try to add one or more test(s) for Replace All, so don't merge yet. |
Comment by MarcelGerber Just pushed some unit tests for "Replace All". Just say if these are too much 😀 We should add some other tests for this, but that isn't my job. |
Comment by njx Thanks for all the additional unit tests! But I'm getting one failure in the new "$0" test--it doesn't seem to be matching the expected text. Are you seeing the same failure? |
Comment by MarcelGerber No, for me every test is working. Which error message do you get? |
Comment by njx Hmmm, it's working fine for me now--not sure what was wrong. Thanks for working on this! Merging. |
Comment by MarcelGerber Thank you. You should add unit tests for normal "Replace All" cases. |
Comment by MarcelGerber
|
Comment by MarcelGerber Or maybe we shouldn't include |
Comment by njx It would make sense to add |
Comment by MarcelGerber Okay, I don't know what to use them for, too. |
Comment by MarcelGerber
|
Comment by njx We have an open card for adding real unit tests for Find/Replace, so that should get done soon. I wouldn't worry about it for this PR as long as your own cases are tested. |
Issue by MarcelGerber
Monday Nov 04, 2013 at 16:23 GMT
Originally opened as adobe/brackets#5840
I picked this idea from adobe/brackets#5772 (comment).
This should be exactly the same dollar-signs-in-replace-with-string behaviour as JavaScript itself haves.
I did a bit of testing and everything worked fine (for example
$1
,$$1
,$$$1
,$
,$$
).FindReplace tests passing, too.
MarcelGerber included the following code: https://github.com/adobe/brackets/pull/5840/commits
The text was updated successfully, but these errors were encountered: