scala / vscode-scala-syntax

Visual Studio Code extension for syntax highlighting Scala sources
https://marketplace.visualstudio.com/items?itemName=scala-lang.scala
MIT License
74 stars 35 forks source link

`@main` not colored consistently #272

Closed NoahELE closed 2 weeks ago

NoahELE commented 2 weeks ago

image

Just like the screenshot above, I'm not sure why the same annotation is colored differently.

The first has semantic token class, while the second has semantic token other

image

image

tgodzik commented 2 weeks ago

Thanks for reporting! Looks like this is an issue with semantic highlight from Metals 🤔 does it happen consistently? I can take a look next week.

NoahELE commented 2 weeks ago

Yes, this happens consistently, usually a call to List constructor will make the @main annotation turn gray. I'm not sure what triggered this exactly.

tgodzik commented 2 weeks ago

Could you post the whole sample? I don't think I can reproduce it currently.

NoahELE commented 2 weeks ago
@main def main1(): Unit =
  println("Hello, world!")

@main def main2(): Unit =
  val list = List(1, 2, 3)
  print(list)

with "editor.semanticHighlighting.enabled": true in vscode settings.

Some vscode color theme does not enable semantic highlighting by default. You can either turn it on manually in setting or use a default theme like Default Dark Modern which enable it by default. I guess that might be the cause.

tgodzik commented 2 weeks ago

Thanks, looks like this happens if a val is in the second main, which is super curious. Do you might opening the issue under scalameta/metals ? That's where the semantic highlight is implemented

NoahELE commented 2 weeks ago

Issue opened here https://github.com/scalameta/metals/issues/6823

tgodzik commented 2 weeks ago

Thanks!