Skip to content

[Bug] shell syntax colors the "-bar" part of "foo-bar" as an attribute #2851

@starpit

Description

@starpit

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Code

Use language=shell and this content:

foo-bar --baz gorp

Actual Behavior

Screen Shot 2021-12-23 at 2 43 23 PM

Expected Behavior

Screen Shot 2021-12-23 at 2 43 52 PM

Additional Context

The relevant regexp is here: https://github.com/microsoft/monaco-editor/blob/main/src/basic-languages/shell/shell.ts#L162

Perhaps the regexp, instead of /-+\w+/ should have a whitespace positive lookbehind? e.g. (?<=\s)-+\w+. I realize that this runs into problems with Safari and old IE... I am not familiar with the internals of monaco-editor, but perhaps there are already runtime guards in place that could be used here.

Or maybe something like [/(\s)(-+[\w-]+/, ["white","attribute.name"]]... but here my knowledge of monaco-editor source is too shallow at the moment to say with any certainty.

fwiw, vscode's markdown preview does not syntax color anything...
Screen Shot 2021-12-23 at 2 44 46 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable buggrammars

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions