microsoft / microsoft/vscode-textmate

`include` grammars don't load within `captures`

Open
#242 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
678
Forks
135
Avg merge
1d 14h
Merged PRs (30d)
2

Description

Embedded grammars are not loaded from disk when inside a captures rule

If the embedded grammar was pre-loaded by another include in the same grammar
OR loaded via another grammar in another language in another file
then it works as expected

  1. Don't open a file that loads the C grammar
  2. Open a file with the following grammar loaded
  3. notice no syntax highlighting. test(5);

image

  1. Close the file
  2. Reload VSCode
  3. Open a C file
  4. Reopen the file with the following grammar loaded
  5. notice syntax highlighting now working

image

{
	"scopeName": "source.capture.load",
	"patterns": [
		{
			"match": ".+",
			"captures": { "0": { "patterns": [ { "include": "source.c" } ] } }
		}
	]
}

from my testing getExternalGrammar() is never run when directly inside captures

related:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how includes nested directly inside a captures rule are resolved, focusing on the reported getExternalGrammar() entry point. Reproduce the issue with the provided TextMate grammar and a C grammar loaded in VS Code. Done means the embedded source.c grammar loads on first use and syntax highlighting works without preloading it elsewhere.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.