Fix PHP highlighting for comment-like strings#317058
Conversation
4a17a50 to
1209bc2
Compare
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
This PR fixes PHP TextMate highlighting so strings beginning with /* are treated as normal strings rather than quoted regex patterns, while preserving highlighting for valid slash-delimited regex strings.
Changes:
- Adds a negative lookahead to PHP single- and double-quoted regex grammar rules to skip
/*. - Updates the PHP grammar updater script so regenerated grammar preserves the patch.
- Adds a colorization fixture and expected results for the reported issue and regex regression coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
extensions/php/syntaxes/php.tmLanguage.json |
Updates regex quoted-string begin patterns to avoid comment-like starts. |
extensions/php/build/update-grammar.mjs |
Applies the same regex grammar patch during grammar regeneration. |
extensions/vscode-colorize-tests/test/colorize-fixtures/issue-204065.php |
Adds PHP fixture covering comment-like strings and valid regex strings. |
extensions/vscode-colorize-tests/test/colorize-results/issue-204065_php.json |
Adds expected TextMate colorization output for the fixture. |
extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/issue-204065_php.json |
Adds empty tree-sitter expected output for the PHP fixture. |
Fixes #204065
This updates the PHP grammar so quoted strings that begin with
/*are not treated as quoted regular expressions. The regex-specific quoted-string rules now skip comment-like starts while preserving highlighting for valid quoted regex patterns.A colorization fixture was added for the reported case, including single-quoted and double-quoted regex patterns to cover the existing behavior.
Validation:
npm run test-extension -- -l vscode-colorize-tests --grep issue-204065