Skip to content

Fix "inside" broken with mixed quote types#3170

Draft
phillco wants to merge 2 commits intomainfrom
fix/3109-inside-mixed-quotes
Draft

Fix "inside" broken with mixed quote types#3170
phillco wants to merge 2 commits intomainfrom
fix/3109-inside-mixed-quotes

Conversation

@phillco
Copy link
Member

@phillco phillco commented Feb 14, 2026

Summary

Fixes #3109.

  • When two ambiguous delimiters (like single quotes) matched in getSurroundingPairOccurrences, the stack truncation (openingDelimitersStack.length = index) destroyed all stack entries above the match — including unrelated delimiter types (backticks) pushed between the matched pair
  • Now uses splice(index, 1) for ambiguous (side === "unknown") delimiters to remove only the matched entry, preserving other delimiter types on the stack
  • Non-ambiguous delimiters (like parentheses, side === "right") still truncate the stack to enforce proper nesting

Test plan

When two ambiguous delimiters (like single quotes) matched, the stack
truncation destroyed all entries above the match — including unrelated
delimiter types (backticks) pushed between the matched pair. Use splice
instead of truncation for ambiguous delimiters to preserve unrelated
stack entries.
@phillco phillco requested a review from a team as a code owner February 14, 2026 20:52
@AndreasArvidsson AndreasArvidsson marked this pull request as draft February 15, 2026 04:04
@AndreasArvidsson
Copy link
Member

This implementation still isn't correct. The original implementation was on purpose. We don't support overlapping scopes. Nested scopes yes, but not overlapping.

What we want is some logic to determine that the first delimiter in this example is the one that shouldn't be used.

aaa's `bbb 'ccc'`
`ddd`

The desired result is

`bbb 'ccc'`
'ccc'
`ddd`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"inside" broken in particular configuration of quotes

2 participants