Fix escaped quotes handling in delimiter selection for JSON strings #53
  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.
  
    
  
    
Problem
The "Select text between quotes" functionality was incorrectly handling escaped quotes in JSON strings and similar contexts. When selecting text in strings like
"[{\"prop1\":0,\"prop2\":\"value2\"]", the delimiter matching would stop at the first escaped quote (\") instead of finding the actual closing quote.Issue scenarios:
1:35but got1:4(stopped at first\")5:10(prop1) but got5:11(prop1\)Solution
Enhanced the delimiter matching logic to properly detect and handle escape sequences:
Key Changes
isEscapedQuote()function counts consecutive backslashes to determine if a quote is escapedfindOpeningQuote()andfindClosingQuote()to match escaped quotes with escaped quotes, unescaped with unescapedImplementation Details
The enhanced logic now:
\"as escaped vs"as unescaped\\\"(escaped) vs\\"(not escaped)Test Results
✅ Scenario 1: Position 1 now correctly selects
1:35(entire JSON content)✅ Scenario 2: Position 5 now correctly selects
5:9(prop1without escape character)Backward Compatibility
Fixes #50.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.