Skip to content

Syntax highlighting: First character of line treated as comment #985

@allefeld

Description

@allefeld

The first character of a line in a qmd document is (sometimes) gray instead of the color of the rest of the line. That happens with a plain paragraph, a heading (first "#"), a blockquote (">"), inside the YAML block etc.

From "Developer: Inspect Editor Tokens and Scopes", it appears that this first character is classified as a comment, and therefore has the comment color (gray in my syntax theme):

Image

The gray color appears slightly later than the regular color, i.e. first coloring is correct, then first characters become gray, as if there is a second pass of syntax highlighting.

Strangely, this glitch is triggered when I execute a user task:

    {
      "label": "My Quarto Preview",
      "type": "shell",
      "command": "quarto-preview '${file}'",
      "isBackground": true,
      "presentation": {
        "reveal": "always",
        "panel": "new",
        "close": false
      },
      "runOptions": {
        "instanceLimit": 5,
        "instancePolicy": "terminateOldest"
      },
      "problemMatcher": []
    }

quarto-preview is a bash script which wraps quarto preview --no-browser. It implements custom port finding logic, and then copies the URL output by Quarto to the clipboard, to be pasted manually into "Simple Browser". It is a workaround for quarto preview having problems with file names or a path which contain spaces.

The script itself doesn't interact with VS Code in any way – except maybe quarto does, despite --no-browser?

Moreover, the problem is not triggered if the task is started through "Tasks: Run Task", only if started via a keyboard shortcut:

{
        "key": "ctrl+shift+k",
        "command": "workbench.action.tasks.runTask",
        "args": "My Quarto Preview",
        "when": "editorTextFocus && editorLangId == 'quarto'"
    }

The problem remains after the task is stopped, and even if the editor is closed and reopened. Closing and reopening the project in VS Code reverts it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvscode

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions