Repository navigation
Preserve literal dollars in case-converted search replacements - #334710
Open
Suzu (Suzu1Dev) wants to merge 1 commit into
Open
Suzu (Suzu1Dev) wants to merge 1 commit into
Suzu (Suzu1Dev) wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Workspace Search reinterprets dollar sequences in case-converted captures as replacement syntax. Searching
^(foo.*)$infoo$1and replacing with\U$1currently producesFOOfoo$1; this change producesFOO$1in both the preview and the saved file.Fixes #334709.
Collect the converted capture separately and escape its literal dollars before appending it to the replacement template. Other capture substitutions continue through the existing path. Add seven regression cases covering capture references, whole-match/prefix/suffix references, escaped dollars, named-reference text, and mixed converted/unconverted captures.
Related to #299365 and #326451, which handle
$$entered in the replacement field. That PR does not cover dollar sequences in case-converted captured text. This branch is based directly onmainand does not depend on #334698.Validation
On macOS arm64 with Node 24.18.0:
git diff --checkpass.--disable-extensions, verified the Search view preview and actual Replace All edits in both baseline and fixed Code OSS:foo$1,foo$&, andfoo$$now becomeFOO$1,FOO$&, andFOO$$.scripts/test.sh --runGlob 'vs/{workbench/services/search,workbench/contrib/search,editor/contrib/find}/test/**/*.test.js' npm run eslint -- src/vs/workbench/services/search/common/replace.ts src/vs/workbench/services/search/test/common/replace.test.ts npm run precommit -- src/vs/workbench/services/search/common/replace.ts src/vs/workbench/services/search/test/common/replace.test.tsRefreshed the two changed JavaScript outputs using esbuild with the repository's transpile settings and reused the existing complete build. Full typecheck, full rebuild, and Windows/Linux validation were not rerun for this change.