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

VSCode 1.92 YAML grammar breaks MDX syntax highlighting #224862

Closed
Tracked by #1
remcohaszing opened this issue Aug 5, 2024 · 18 comments
Closed
Tracked by #1

VSCode 1.92 YAML grammar breaks MDX syntax highlighting #224862

remcohaszing opened this issue Aug 5, 2024 · 18 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug grammar Syntax highlighting grammar verified Verification succeeded
Milestone

Comments

@remcohaszing
Copy link
Contributor

Does this issue occur when all extensions are disabled?: No, VSCode 1.92 YAML grammar updates cause a regression when embedded in the MDX syntax highlighting.

  • VS Code Version: 1.92
  • OS Version: Pop!_OS 22.04

Steps to Reproduce:

  1. Launch VSCode with code --disable-extensions
  2. Install the unifiedjs.vscode-mdx extension
  3. Create a file named whatever.mdx with the following content:
    ---
    foo: 1
    ---
    
    This is highlighted as a YAML string
    
    # This is highlighted as a YAML comment
    
    This is highlighted as a YAML error

Notice how the syntax highlighting is broken. This was not the case in VSCode < 1.92.

Broken MDX syntax highlighting

Removing all lines from the frontmatter fixes it:

---
---

This is highlighted as a YAML string

# This is highlighted as a YAML comment

This is highlighted as a YAML error

Proper MDX syntax highlighting

Proper MDX syntax highlighting

A workaround is to install the redhat.vscode-yaml extension. This uses a different YAML grammar.

Related issues:

@mjbvz
Copy link
Collaborator

mjbvz commented Aug 5, 2024

Seems like this came in with the new yaml grammar #219833

I believe that grammars that use source.yaml need to switch to use a begin/while pattern for the front matter like in this change: microsoft/vscode-markdown-tm-grammar#162

@RedCMD Is there anything that can be done on the yaml grammar side to handle this more elegantly?

@mjbvz mjbvz added the grammar Syntax highlighting grammar label Aug 5, 2024
@mjbvz mjbvz added this to the August 2024 milestone Aug 5, 2024
@RedCMD
Copy link
Contributor

RedCMD commented Aug 6, 2024

@mjbvz I'll see what I can do

its caused by this line being too greedy
https://github.com/RedCMD/YAML-Syntax-Highlighter/blob/8de6455b5306c4963eeaef692ee3375d80a23f0e/syntaxes/yaml-1.2.tmLanguage.json#L15
however I can't just restrict it, otherwise the cross-document VERSION feature won't work

there definitely is quite a few extensions using the old FrontMatter code https://github.com/search?q=lang%3Ajson+A-%7B3%7D&type=code 200+

@RedCMD
Copy link
Contributor

RedCMD commented Aug 6, 2024

I think I've got something working
found a few VSCode TextMate bugs at the same time

image

you can test out the latest changes by installing my pre-release YAML extension

@alexr00 alexr00 added the candidate Issue identified as probable candidate for fixing in the next release label Aug 6, 2024
@alexr00
Copy link
Member

alexr00 commented Aug 6, 2024

For the recovery release, I'm going to roll back to the old grammar. In insiders, I'll fix forward and grab your fix @RedCMD.

@archiewood
Copy link

is there a way to roll back to the previous grammar while we await a release?

I can tell our users to install the redhat extension, but a fix that required no action of them would be better

@alexr00
Copy link
Member

alexr00 commented Aug 9, 2024

The release went out yesterday.

@archiewood
Copy link

archiewood commented Aug 9, 2024

Thank you, I upgraded and this seems fixed in 1.92.1

@aeschli
Copy link
Contributor

aeschli commented Sep 12, 2024

Verified in
1.93.1
Commit: 38c31bc
Date: 2024-09-11T17:20:05.685Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Linux x64 5.15.0-119-generic

@Mti-isf
Copy link

Mti-isf commented Oct 2, 2024

[](แชร์ & ชวนเพื่อนจองทริป รับเลย Trip Coins 200 บาท! ยิ่งแชร์ยิ่งคุ้ม บอกต่อแอปดีๆ ให้เพื่อนของคุณเลย
https://th.trip.com/sale/4283/referee.html?locale=th-TH&referCode=603DE9E1C7E008C5F2B70DEE7ECF89A1)

@FragsterAt
Copy link

FragsterAt commented Oct 10, 2024

In 1.94.1 vs code corrupts code highlighting after YAML block again (
vuejs/language-tools#4831

screenshot of vscode 1.93.0
Image

@alexr00 alexr00 reopened this Oct 11, 2024
@alexr00 alexr00 removed the verified Verification succeeded label Oct 11, 2024
alexr00 added a commit that referenced this issue Oct 11, 2024
@alexr00
Copy link
Member

alexr00 commented Oct 11, 2024

Thanks for reporting @FragsterAt. I'm reverting the YAML grammar in the main branch, so the next VS Code insiders will not have this issue. We've missed the chance to get the fix into 1.94.2, but if we have a 1.94.3, then I'll make the change there too.

@alexr00
Copy link
Member

alexr00 commented Oct 11, 2024

Actually, @FragsterAt I'm not seeing the same issue:

Image

@alexr00
Copy link
Member

alexr00 commented Oct 11, 2024

Ah, I had an extension installed that was providing a different yaml grammar. I still see the bug.

alexr00 added a commit that referenced this issue Oct 11, 2024
@FragsterAt
Copy link

FragsterAt commented Oct 11, 2024

Actually, @FragsterAt I'm not seeing the same issue:

Please look in vuejs/language-tools#4831

In 1.93.1 All was ok, but in 1.94.1 it broken again.

.vue files can have "sections" in different languages, yaml section breaks highlighting (now a little different in comparison to 1.93.0, but still corrupted) in next sections

with yaml block in 1.94.1 (different from 1.93.0)
Image
without yaml block in 1.94.1
Image

https://gist.github.com/FragsterAt/213f76e1e6a4592ac071236849af6392

@bpasero bpasero removed the candidate Issue identified as probable candidate for fixing in the next release label Oct 17, 2024
@bpasero
Copy link
Member

bpasero commented Oct 17, 2024

Moving to the normal October milestone.

@alexr00
Copy link
Member

alexr00 commented Oct 17, 2024

Grammar revert is already done in main.

@alexr00 alexr00 closed this as completed Oct 17, 2024
RedCMD referenced this issue in RedCMD/YAML-Syntax-Highlighter Oct 21, 2024
@rzhao271 rzhao271 added the verified Verification succeeded label Oct 23, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug grammar Syntax highlighting grammar verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

10 participants