microsoft / microsoft/vscode-textmate

Scope inspector bug when extending C++ syntax highlighting through Textmate grammar

Open
#163 4 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

  • VS Code Version: 1.63.2
  • OS Version: Darwin x64 21.1.0

Steps to Reproduce:

  1. created a vscode extension
  2. contributed to C++ grammar by writing the following Textmate grammar file (see snippet 1) and setting the extension's package.json to contribute correctly (see snippet 2)
  3. built the extension and ran it on Extension Development Mode
  4. used Inspect Editor Scopes tool to check a token that matches to a custom defined Regex within my extended Textmate grammar file
  5. PROBLEM: inspector doesn't show my custom textmate scope

Snippet 1)

{
	"scopeName": "source.cpp",
	"fileTypes": [
		"cpp",
		"c++",
		"c"
	],
	"patterns": [
		{
			"include": "#expression"
		}
	],
	"repository": {
		"expression": {
			"patterns": [
				{
					"include": "#clog-db"
				},
				{
					"include": "#indent-DB"
				},
				{
					"include": "#array-db"
				},
				{
					"include": "#sample"
				}
			]
		},
		"clog-db": {
			"begin": "^\\s*clog",
			"end": "<<[^;]+;",
			"name": "cpdebug.clog"
		},
		"indent-DB": {
			"match": "^\\s*DB\\(\\);",
			"name": "cpdebug.indentdb"
		},
		"array-db": {
			"match": "^\\s*dba(2)?\\([^;]+\\);",
			"name": "cpdebug.arraydb"
		},
		"sample": {
			"match": "clog",
			"name": "cpdebug.sample"
		}
	}
}

Snippet 2:

	"contributes": {
			"languages": [
				{
					"id": "cpp",
					"extensions": [
						".cpp"
					]
				}
			],
			"grammars": [
				{
					"language": "cpp",
					"scopeName": "source.cpp.debug",
					"path": "./syntaxes/cpp.tmGrammar.json",
					"injectTo": [
						"source.cpp"
					]
				}
			]
		},

image

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

Reproduce the issue using the provided TextMate grammar snippet, extension package.json contribution, and Extension Development Mode. Start with the Inspect Editor Scopes behavior for the custom regex matches and compare the injected source.cpp grammar configuration. Done means the inspector displays the custom cpdebug scopes for matching tokens.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
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.