VSCode's tmLanguage support cannot match zero-width `begin` and `end` correctly.
See original GitHub issueThe syntax is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>testlang</string>
</array>
<key>name</key>
<string>testlang</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#indentedVerbatimOp</string>
</dict>
</array>
<key>repository</key>
<dict>
<key>indentedVerbatimOp</key>
<dict>
<key>begin</key>
<string>^([ \t]*)(?=(.*?)\|$)</string>
<key>end</key>
<string>^(?!\1[ \t])(?=[ \t]*\S)</string>
<key>name</key>
<string>string.unquoted.verbatim.youki</string>
</dict>
</dict>
<key>scopeName</key>
<string>text.testlang</string>
<key>uuid</key>
<string>159375af-d9b4-448c-a9da-d235eadf3556</string>
</dict>
</plist>
It matches indented block with a leading line ending with a bar (|
). I’ve found that Code cannot match the block’s ending, which is zero-width:
Sublime can match it perfectly:
If I add some character to the end tag then Code works again:
<key>end</key>
<string>^(?!\1[ \t])(?=[ \t]*\S)xx</string>
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
VSCode's tmLanguage support cannot match zero-width ...
be5invis changed the title VSCode's tmLanguage support cannot zero-width begin and end matches correctly. VSCode's tmLanguage support cannot ...
Read more >matching begin and pattern without end with tmLanguage
I'm trying to define a language using tmLanguage for syntax highlighting in vscode. I have the following rule.
Read more >awesome-vscode | A curated list of delightful VS Code ...
A curated list of delightful Visual Studio Code packages and resources. ... Unlike some other editors, VS Code supports IntelliSense, linting, ...
Read more >Syntax Highlight Guide | Visual Studio Code Extension API
Syntax Highlight Guide. Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor.
Read more >VSCodeSetup-x64-1.40.2.exe - Hybrid Analysis
Not all malicious and suspicious indicators are displayed. Get your own cloud service or the full version to view all details. Malicious Indicators...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I still don’t understand why we do this:
begin
that matches the beginning location of an empty location, theend
pattern will go forward from that point on instead of starting matching at that point, causing thebegin
andend
to consume the same zero-width part.\G
for boundaries. What’s a migration path for them? I don’t want to add(?=.)
to each of them: https://github.com/Microsoft/vscode/commit/ccd3c1f94e64f7798ddf30d187274bd8905593fd./cc @aeschli
@be5invis You can (re)tokenize the captured text via
beginCaptures
:See here an example where it is done for a match
captures
, but the principle is the same: https://github.com/Microsoft/vscode-textmate/blob/master/test-cases/first-mate/fixtures/makefile.json#L350Here the match captures the entire line which is then further (re)tokenized to assign more fine-grained tokens. You just need to convert that into equivalent plist.