question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VSCode's tmLanguage support cannot match zero-width `begin` and `end` correctly.

See original GitHub issue

The 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: image

Sublime can match it perfectly: image

If I add some character to the end tag then Code works again:

            <key>end</key>
            <string>^(?!\1[ \t])(?=[ \t]*\S)xx</string>

image

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
octrefcommented, Sep 25, 2018

I still don’t understand why we do this:

/cc @aeschli

1reaction
alexdimacommented, May 27, 2016

@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#L350

Here 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. image

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found