vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Syntax highlighting not available until file is refreshed

Open just-ero opened this issue 1 year ago • 1 comments

Type: Feature Request

Description

When opening a C# project with Visual Studio Code and opening one of the source code files within a short amount of time, correct syntax highlighting will not be available.

Once the project/solution is done configuring, any refresh of the file (for examples scrolling or switching to another file and back) will result in highlighting to become available.

It would be nice if the user didn't have to do this.

Extension version: 2.15.30 VS Code version: Code 1.86.1 (31c37ee8f63491495ac49e43b8544550fbae4533, 2024-02-07T09:08:20.941Z) OS version: Windows_NT x64 10.0.22631 Modes:

just-ero avatar Feb 13 '24 09:02 just-ero

This is a known bug - we send semantic token refresh notifications to the VSCode client when we load the project, telling it that the semantic tokens are out of date. However VSCode will not actually refresh the tokens until the user interacts with the document (e.g. scrolling, making an edit, etc).

The VSCode behavior of lazily refreshing in response to a refresh notification is generally fine - the majority of the time we need to refresh, only a few semantic tokens are out of date. When we're loading the project though it would be nice if we could force the client to refresh because we know everything is incorrectly colorized until the project finishes loading.

I don't believe we can manually force a refresh today - likely need support on the VSCode side for that. Assigned to me to do some more investigation, but for now once the project finishes loading you'll need to interact with the document to get the colors to load (scroll, edit, switch docs, etc).

dibarbet avatar Feb 16 '24 00:02 dibarbet