Skip to content

fix: handle double quotes in regex scanner to allow spaces in glob patterns#322

Open
Whoaa512 wants to merge 1 commit intotree-sitter:masterfrom
Whoaa512:fix-glob-pattern-quoted-spaces
Open

fix: handle double quotes in regex scanner to allow spaces in glob patterns#322
Whoaa512 wants to merge 1 commit intotree-sitter:masterfrom
Whoaa512:fix-glob-pattern-quoted-spaces

Conversation

@Whoaa512
Copy link

@Whoaa512 Whoaa512 commented Feb 5, 2026

Fixes #321

Problem

Glob patterns with quoted strings containing spaces failed to parse in [[ ]] test commands:

# This failed to parse
[[ "${tmp}" = *"A B"* ]]

# Real-world example that also failed
[[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]

Root Cause

The scanner tracked in_single_quote state but not in_double_quote when scanning REGEX_NO_SPACE tokens. When encountering a space inside double quotes, it incorrectly treated it as a regex-terminating space.

Fix

  • Added in_double_quote to the State struct in the scanner
  • Handle " character similar to ' for entering/exiting quoted strings
  • Updated all three was_space checks to also consider in_double_quote

Testing

  • Added test case for glob patterns with quoted spaces
  • All 101 tests pass

…tterns

Fixes tree-sitter#321

The scanner was tracking single-quoted strings but not double-quoted strings
when scanning REGEX_NO_SPACE tokens. This caused glob patterns like *"A B"*
to fail parsing because the space inside the double quotes was treated as
a regex-terminating space.

Added in_double_quote tracking to the State struct and updated all three
was_space checks to also consider whether we're inside a double-quoted string.
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.

Glob pattern with quoted string containing spaces fails to parse in [[ ]]

1 participant

Comments