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

In code mode, text with $$ cannot be replaced. #1575

Open
ChrisYuan1 opened this issue Feb 21, 2024 · 5 comments
Open

In code mode, text with $$ cannot be replaced. #1575

ChrisYuan1 opened this issue Feb 21, 2024 · 5 comments
Labels

Comments

@ChrisYuan1
Copy link

Animation

@josdejong
Copy link
Owner

You an use $$$$add as replacement text. Apparently the $ character needs to be escaped in the search box of Ace editor. It may be some feature to replace a pattern or so, but I couldn't find any documentation about that.

@Davidliu11
Copy link

Davidliu11 commented Feb 22, 2024

Hi @josdejong @ChrisYuan1, I am not sure if this need to be fixed for the Ace-editor, but I think I found root cause for this issue.
image
See the code above in the Ace editor repo. the replacement string will be handled like the red line marked.
In the case of this issue the replacement is "$$xxxxx", from the doc in MDN the '$$' is a special replacement pattern.
image

Then after the 'replace', the replacement string will be something '$xxxx'.

@josdejong
Copy link
Owner

Ahhh, wow, so it is actually a feature that originates in JavaScript's String.prototype.replace(). That explains it. Thanks for figuring this up.

I think we can indeed argue that Ace should fix this, since when the search text is a string (and not a regexp), the $ sign can't be applicable. Ace editor could escape $ signs by escaping them as $$.

@Davidliu11
Copy link

@josdejong The Ace-editor guy said they would add fix for this issue. ajaxorg/ace#5486

@josdejong
Copy link
Owner

That is good news! Thanks for opening the issue at Ace.

@josdejong josdejong added bug and removed question labels Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants