Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Red text highlighting in VSCode extension when more than one line in the title block #501

Closed
dbdean opened this issue Aug 2, 2024 · 14 comments · Fixed by #506
Closed

Red text highlighting in VSCode extension when more than one line in the title block #501

dbdean opened this issue Aug 2, 2024 · 14 comments · Fixed by #506

Comments

@dbdean
Copy link

dbdean commented Aug 2, 2024

I'm running the Quarto VSCode Extension version 1.113.0, inside of a dev container. I seem to have the same problem when downgrading to 1.112.0, so I don't think the following problem is directly related to a change in the extensions itself.

I'm not sure what has changed recently to cause this, but whenever I open a qmd file with more than one line in my title block, the quarto extension is causing all python code to show up as red text.

For example, this is fine:

image

As is this:

image

But if I add another line to the title block, I get red python text:

image

Even just an extra blank line will do it:

image

This has only just started happening for me, and VSCode's extension bisect has confirmed that it is being caused by the Quarto Extension.

Any ideas on what could be happening and how to fix it would be very appreciated. It appears to have no impact on the functionality otherwise, but it is a lot harder to follow the code when everything is red.

@dbdean
Copy link
Author

dbdean commented Aug 2, 2024

Looking at the token inspector, it seems to think it should be yaml there, and is doesn't like it as yaml:

image

Whereas with just the single-line title block, it recognises it as python:

image

@benesom
Copy link

benesom commented Aug 2, 2024

I can report the same behavior on MacOs 14.5 (23F79) with VScode 1.92.0.

@alptemiz
Copy link

alptemiz commented Aug 2, 2024

Same here, using Windows with VS Code 1.92.0, Quarto 1.5.56, and R 4.4.1.

If you remove the YAML codes at the top, you'll notice that your code appears with normal syntax highlighting. However, this workaround will prevent your code from rendering properly.

A temporary solution is to downgrade to VS Code 1.91.1, where everything works fine.

The Quarto team will likely resolve this issue in the next version. Until then, don't forget to disable auto-updates in VS Code to avoid any disruption.

@memeplex
Copy link

memeplex commented Aug 2, 2024

Indeed, this fails in the simplest of the examples:

image

It's not immediately visible at that level, but the grammar is already wrong.

Inside second level sections the problem surfaces:

image

@memeplex
Copy link

memeplex commented Aug 2, 2024

microsoft/vscode#220026

@memeplex
Copy link

memeplex commented Aug 2, 2024

Also, notice that I'm using pandoc syntax, but it's exactly the same when both delimiters are ---.

@SaintRod
Copy link

SaintRod commented Aug 2, 2024

Experiencing the same behavior on Linux Mint 21.3 with VS Code v1.92.0 Quarto v1.5.54

@memeplex
Copy link

memeplex commented Aug 2, 2024

According to microsoft/vscode#224627 (comment) it's not a regression in VSCode but that the qmd grammar should follow the new grammar in VSCode.

@RedCMD
Copy link

RedCMD commented Aug 2, 2024

FrontMatter integration should be updated to match Markdowns

frontMatter:
begin: \A-{3}\s*$
contentName: meta.embedded.block.frontmatter
patterns:
- {include: source.yaml}
end: (^|\G)-{3}|\.{3}\s*$

microsoft/vscode-markdown-tm-grammar#162

https://github.com/microsoft/vscode-markdown-tm-grammar/blob/main/markdown.tmLanguage.base.yaml#L202-L216

@mcanouil
Copy link
Contributor

mcanouil commented Aug 5, 2024

Weirdly, it does not seem to happen on macOS, but it does on UNIX and Windows system.

Screen.Recording.2024-08-05.at.13.10.20.mov

@mcanouil
Copy link
Contributor

mcanouil commented Aug 5, 2024

@RedCMD From what I understand, a simple PR to update the definition would be enough, correct?

@mcanouil
Copy link
Contributor

mcanouil commented Aug 5, 2024

Ok, I've made a PR and reached out to the repository owners.

@memeplex
Copy link

memeplex commented Aug 5, 2024

Weirdly, it does not seem to happen on macOS

It does happen on macOS Sonoma for me.

@mcanouil
Copy link
Contributor

mcanouil commented Aug 5, 2024

Thanks.

The fix is being tested to ensure it does not break other things that use the extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants