Skip to content

TextMate grammar regexes able to only match a single line #32

Closed

Description

@mjbvz

From Raul Tambre (@tambry) on December 31, 2016 16:20

Image of improper multiline syntax highlighting

Everything between the parentheses should be coloured green, but the matching stops after the first line ends.

  • VSCode Version: 1.8.1
  • OS Version: Ubuntu 16.10 64-bit (4.8.0-30-generic)

Steps to Reproduce:

  1. Clone this minimal repro sample.
  2. Open the folder of the sample in VS Code.
  3. Press F5 to run the extension in a new VS Code instance.
  4. In the new instance open the test.matchbug file that's in the repro sample's root directory.
  5. Code is improperly highlighted.

How the regex should match

Copied from original issue: microsoft/vscode#17964

Activity

  1. tambry commented on Jan 3, 2017

    @tambry

    Uh, that's unfortunate. So I guess making really good TextMate grammars is impossible for certain languages. I encountered this issue when trying to develop a grammar for CMake, where commands are often long and are split onto many lines.

    Would it be maybe possible to consider supporting a special value or property to allow multiline regexes? Ie. multiline: true would enable multiline regex matching in the current and sub-scopes, unless explicitly disabled again.
    This would prove very useful in languages that may have commands on multiple lines and for making better highlighting through grammar files. Ie. some languages have special constants that are only accepted by a single command, so you wouldn't want to highlight them anywhere else, except when they're being passed to that command.

  2. tambry commented on Jan 4, 2017

    @tambry

    Monarch definitely seems more flexible and usable than TextMate for such grammars. Though an actual API for parsing and highlighting would be even better.
    There does seem to be a feature requests for this in microsoft/vscode#216. I guess I'll have to wait and live until someone actually implements a better way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions