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

[BUG] VS Code Extension - Weird Syntax Highlighting with raises Keyword #3924

Open
johnsoez4 opened this issue Jan 3, 2025 · 4 comments
Open
Assignees
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@johnsoez4
Copy link

Bug description

The color weirdness shown in the first screenshot appears in the Mojo code after a function uses the raises keyword. In this example fn main() raises: appears at the beginning of a file. The colors look OK if raises is removed.
Asked to create a bug report by @ehsanmok (Ehsan Kermani).
Discord: https://discord.com/channels/1087530497313357884/1224434323193594059/1324229203163615273

Steps to reproduce

fn main() raises:
# fn main():  # OK
    pass


# Mojo modules
from python import Python
from math import ceil
from testing import assert_true
from time import sleep

Uses the raises keyword - KO
image

Removed the raises keyword - OK
image

System information

magic 0.5.1 - (based on pixi 0.37.0)
Mojo 🔥 (nightly): 2024.12.2805
Ubuntu: 24.10

VS Code:
Version: 1.96.0
Commit: 138f619c86f1199955d53b4166bef66ef252935c
Date: 2024-12-11T02:29:09.626Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 6.11.0-13-generic snap
@johnsoez4 johnsoez4 added bug Something isn't working mojo-repo Tag all issues with this label labels Jan 3, 2025
@gphlipot
Copy link

gphlipot commented Jan 4, 2025

Do you have the vscode setting editor.semanticHighlighting.enabled set to true? I only see the weird highlighting when I have it set to true. If I set it to false or "configuredByTheme", then I get normal syntax highlighting. I also see this same behavior in both the nightly and the released versions.

When it is set to true, I think this causes the LSP to be used for syntax highlighting instead of the textmate grammar. And it seems like the syntax highlighting from the LSP is weird.

@johnsoez4
Copy link
Author

The VS Code setting is Enabled as selected in the dropdown configuredByTheme (default) versus an explicit True or False.
image

@johnsoez4
Copy link
Author

johnsoez4 commented Jan 5, 2025

This issue with the VS Code extension started with version 2024.12.2305. See below for the versions I checked today. I also reconfirmed that the immediately prior version (2105) was still OK.

Mojo 🔥 (nightly):

  • 2024.11.3005 - OK
  • 2024.12.1405 - OK
  • 2024.12.2105 - OK
  • 2024.12.2305 - KO <--
  • 2024.12.2405 - KO
  • 2024.12.2805 - KO

@johnsoez4
Copy link
Author

Per GitHub, commit 2024.12.2305 updated five (5) magic.lock files to point to latest nightly version: 25.1.0.dev2024122305.
Raw Mojo diff: f4b34fc...22aa305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

3 participants