microsoft / microsoft/vscode-textmate
potentially unwarned failure behavior when INCLUDE cannot be resolved
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 678
- Forks
- 135
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 2
Description
In an INCLUDE in the patterns of a repository item, I was trying to find a way to say 'continue the parent rules here' and even though I have looked through the source and find no such way, my first attempt with $parent worked! I can be pretty sure it works, because this item is used in two different parents which expose different syntaxes, and both work, and also that rules above the parent do not come in to play either. Exactly what I wanted.
But I am not sure it was meant to be. I am pretty sure that $parent causes the code to look for an external grammer, and apparently, when its not found, somehow it slips back in to the parent rule set. This might be because I have not defined any other rules inside this BEGIN-END rule block. (actually pretty sure on this because I tried it somewhere else by changing the last include to try to get all the parent items and I got only the ones already successfully included)
I also checked that anything that does not produce a valid include seems to do the same thing, including "#" and "$", or even "#blah" which doesn't match any repository items.
If I set the INCLUDE to "" then no rules are processed at all inside the block.
Here is the block in question: (revised from https://github.com/mmims/language-batchfile)
"command_set_group": {
"patterns": [
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.section.group.begin.batchfile"
}
},
"end": "\\)|$",
"endCaptures": {
"0": {
"name": "punctuation.section.group.end.batchfile"
}
},
"patterns": [
{
"include": "$parent"
}
]
}
]
}
I would have expected that INCLUDE's that couldn't be found would react the same as "".
I really think textmate could use a $parent include mechanism, as this greatly simplifies blocks. In the case of batchfile, the SET /A command utilizes some operators that can only be used directly if the expression is enclosed in quotes, so two separate block rules would be needed to handle blocks inside quotes and outside quotes because different includes for operators would be needed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied TextMate grammar block with $parent, invalid includes such as # or $, and an empty include. Trace the INCLUDE resolution entry point and compare the resulting rules; done means the behavior is either corrected so unresolved includes act like empty includes or clearly documented as intentional.
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