ajaxorg/ace

(Search): Replacement string start with '$$' only have one '$' in effect

Closed this issue · 2 comments

Describe the bug

When find and replace any string in the code, If I use string like '$$xxxx' as the replacement string then then result would be '$xxxx', only one '$' left.

Expected Behavior

Treat '$$xxxx' as a normal string, instead of a special replacement pattern.

Current Behavior

'$$' will be treated as a special replacement pattern.

Reproduction Steps

Use 'ctrl+f' to find and replace, and the replacement string start with double '$'

Possible Solution

Seems this is reasonable behavior for the "string.prototype.replace()", but this is assuming the user to know the internal implementation of the editor.

Additional Information/Context

No response

Ace Version / Browser / OS / Keyboard layout

v1.32.2, Chrome, Windows

Thank you for the report. Indeed ace uses the regular String.prototype.replace, some extra logic would be required to make it work as expected.

replacement = input.replace(re, replacement);

#5488 with a fix was merged, will be available in the next release.