Syntax highlighting: First character of line treated as comment

Open
#985 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript, vscode
Domain
tooling

Research direction

Reproduce the issue in VS Code with a qmd document and the shown keyboard shortcut for “My Quarto Preview”; compare it with “Tasks: Run Task.” Use “Developer: Inspect Editor Tokens and Scopes” to confirm the first character is classified as a comment, and consider the issue complete when starting the shortcut no longer causes that character to change color or persist after reopening the editor.

Written by the indexing model from the issue text.

Description

bug vscode

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.

Dominant language
TypeScript
Stars
645
Forks
62
Avg merge
17h 42m
Merged PRs (30d)
13

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from quarto-dev/quarto

All issues in quarto-dev/quarto

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.