Skip to content

Parse JSON grammars with mixed-case extensions - #305

Open
Ammann Labs (agammann) wants to merge 1 commit into
microsoft:mainfrom
agammann:agammann/fix-json-grammar-extension-case
Open

Ammann Labs (agammann) wants to merge 1 commit into
microsoft:mainfrom
agammann:agammann/fix-json-grammar-extension-case

Conversation

@agammann

Copy link
Copy Markdown

Summary

parseRawGrammar selects the JSON parser only when a filename ends in lowercase .json. A valid JSON grammar named example.JSON or example.Json is sent to the PLIST parser and fails with Near offset 1: expected <.

Make the extension check case insensitive. The regression test exercises both filename variants against the existing lowercase behavior.

Reproduction

const source = '{"scopeName":"source.example","patterns":[]}';
parseRawGrammar(source, 'example.JSON');

On main at dec096bc6ab91710e13023a00d029b8195e26c60, this throws from the PLIST parser. With the fix, it parses the JSON grammar.

Validation

  • The new focused test fails on unmodified upstream and passes with the fix.
  • On Linux with Node 22.23.3, npm ci, npm run compile, and npm test pass: 268 tests passed and one existing test was skipped.
  • git diff --check passes.

@agammann

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

1 participant