microsoft / microsoft/vscode-textmate

Behavior of $base and $self in injection grammars

Open
#117 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

As far as I can tell, $base and $self currently do not work as expected in external injection grammars. Both seem to resolve to the injection grammar itself.

Instead, here's how I think they should work:

$base in an injection grammar should always be resolved to root grammar (it should have the same behavior as using $base in a normal grammar file that is included from another grammar)

The expected behavior of $self is less clear. I think it would make most sense for $self to resolve to the grammar being targeted by the injection, although you could argue that it could be resolved to the injection grammar itself

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 external injection grammars resolve $base and $self, using the behavior described in this issue as the reproduction target. Confirm that $base resolves to the root grammar, then resolve the remaining ambiguity around whether $self refers to the targeted grammar or the injection grammar and document the chosen behavior in regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.