{{ message }}
Repository navigation
fix(muya): escape braces in a plain-text find query - #5428
Merged
Merged
Conversation
With the regexp option off, matchString escapes the query's regexp
characters but not { and }, so a query like a{2} became a quantifier:
it matched "aa" and never the text a{2}.
This was referenced Sep 16, 2026
Jocs
approved these changes
Sep 17, 2026
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.

Fixes #5427
Summary
With the regexp option off,
matchStringinpackages/muya/src/utils/search.tsescapes the query before building the RegExp, but itsSPECIAL_CHAR_REGclass left out{and}. A query likea{2}therefore became a quantifier: Find highlightedaaand never the texta{2}, and Replace rewrote the wrong text. This adds the two braces to the class. A lone{already worked, since it is literal outside Unicode mode, and escaping it gives the same result.Regexp mode is unchanged: the escaping only runs when
isRegexpis false.Type of change
Test plan
packages/muya/src/utils/__tests__/searchLiteralBraces.spec.tscoversa{2},x{1,3}, a lone brace and the whole-word case. Ondevelop(73b90a7), 4 of its 5 tests fail (expected [ [ +0, 'aa' ] ] to deeply equal [ [ 3, 'a{2}' ] ]); with the fix all 5 pass.npx vitest run src/utils/__tests__/ src/searchpasses the existing search suites too (61 tests), andeslintandtsc --noEmiton muya are clean. I did not try it in the desktop app.Notes for reviewers [optional]
quickOpen.tsin the desktop package builds its file-name RegExp with a similar class that also omits the braces; I left it alone to keep this PR to the editor's Find.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.
Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.