Improve Pair Matching Logic to Skip Parentheses Inside Strings
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
Pair Matching Logic to Skip Parentheses Inside Strings
Issue Content
Description
In the current implementation of PairMatcher, the algorithm does not account for parentheses that may be located inside strings (e.g., "(')')"). This leads to incorrect jump behavior when users expect to skip parentheses within strings rather than treating them as matching pairs.
Steps to Reproduce
- In the editor, input a string such as:
"(')')" - Place the cursor on the first left parenthesis
(. - Use the
%command to attempt to jump to the matching right parenthesis).
Expected Behavior
The cursor should skip the right parenthesis inside the string and jump directly to the external matching right parenthesis.
Actual Behavior
The cursor incorrectly jumps to the right parenthesis inside the string.
Proposed Solution
I plan to add logic in the findPairedChar method to detect whether the current character is inside a string. Specifically, I will introduce a state variable to track whether we are inside a string and skip characters inside strings when processing parentheses. and make sure everything like ciw, ci" works fine
Related Code
findPairedCharmethodPairMatcherclass
Please feel free to let me know if you guys have any suggestions or thoughts.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PairMatcher class and its findPairedChar method, then reproduce the reported case with "(')')" and the % command. Verify that matching skips parentheses inside strings while existing behaviors such as ciw and ci" continue to work; the issue is done when both the reported jump and those commands behave correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100