ionide-vscode-fsharp icon indicating copy to clipboard operation
ionide-vscode-fsharp copied to clipboard

Syntax highlighting inconsistencies

Open MangelMaxime opened this issue 4 years ago • 5 comments

This issue will regroup several observations on the syntax highlighting because I can't seems to isolate one problem. By that, I mean that depending on the rest of the file the errors changes... making it hard to fill one issue per error.

Inconsistency between records and anonymous records

image

See how account3 and account2 don't use the same blue.

Inconsistency between records and records inside string interpolation

image

See how id is blue or white.

Highlighting change depending on the file content

https://user-images.githubusercontent.com/4760796/126622774-602ae5e8-aeeb-4997-98c3-293df1c08ffa.mp4

See how the line let z = ... changes

https://user-images.githubusercontent.com/4760796/126623311-afca440a-2a38-4040-bb17-5b4efec7de1b.mp4

See how the different lines changes.

Highlighting changes depending on the file scrolls level

I am unsure if this is an Ionide bug or VSCode for this one

https://user-images.githubusercontent.com/4760796/126623107-5e7b4b02-4684-46ae-9c64-6af4a5a1a146.mp4

See how the line let z = ... changes

Depending on how I scroll this line changes of colours too:

image

image

Machine info

  • OS: Windows
  • .NET SDK version: [e.g. 5.0.100] 5.0.301
  • Ionide version: [e.g 5.0.1, don't use descriptions like latest ] 5.5.9

MangelMaxime avatar Jul 22 '21 10:07 MangelMaxime

Hey @MangelMaxime :wave:,

Thanks for backing our project. If possible, We will handle your issue with priority support. To make sure we don't forget how special you are, we added a backer label to your issue.

Thanks again for backing us :tada:!

Hi, was just looking for an existing issue that closely matched one that I am encountering and I think this is it.

In this image: image Notice that the type parameter (<>) braces and parens (()) are not highlighted consistently.

Version: 1.66.2 (user setup)
Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
Date: 2022-04-11T07:46:01.075Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.19044

Ionide last updated at: 3/13/2022, 21:30:27


I would also be happy to contribute if pointed in the right direction. 😸

tymokvo avatar Apr 15 '22 02:04 tymokvo

What would be really interesting in this case is what the 'semantic token scopes' are for each of the mismatched <> and () in your example. If you open the 'inspect tokens' command

image

the semantic token scopes and textmate info would be super useful:

image

This will lead us to two solutions:

  • if there are no semantic scopes, but there are textmate scopes, then we need to update the ionide-fsgrammar
  • if there are semantic scopes, then we're reliant on the SemanticClassification service from the compiler, and we'd need more information to come out of it.

There can be a bit of lag, and so in this PR I experimented with doing syntax-based highlighting directly in the language server. This would be pretty fast, and give us a ton of control, and it would be a good candidate for pushing down to the compiler itself once completed.

baronfel avatar Apr 15 '22 02:04 baronfel

<>

Left

image

Right

image

()

Left

image

Right

image

Since there are missing semantic scopes (for >), I guess it's ionide-fsgrammar? The parens seem like they are just not being rendered correctly, though as they are both assigned the color #ddbb88

tymokvo avatar Apr 15 '22 03:04 tymokvo

What's weird is that the > seems right to me - a textmate scope of keyword.symbol.fsharp. The other cases, with the <, (, and ) symbols being given function semantic token scopes, is interesting. That will require doing some debugging in the semantic highlighting LSP call in FsAtutoComplete, which can be a bit finicky. The questions we'll have to answer is:

  • Are we getting correct ranges back from the compiler for these symbols?
  • Are we translating those ranges correctly to LSP ranges (the main difference is that lines/columns for the compiler and the LSP protocol have different base offsets (0 or 1) and so we have to be careful when translating

baronfel avatar Apr 15 '22 03:04 baronfel