You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
findPairedChar method
PairMatcher class
Please feel free to let me know if you guys have any suggestions or thoughts.
The text was updated successfully, but these errors were encountered:
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
"(')')"
(
.%
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 likeciw
,ci"
works fineRelated Code
findPairedChar
methodPairMatcher
classPlease feel free to let me know if you guys have any suggestions or thoughts.
The text was updated successfully, but these errors were encountered: