Update: this has been fixed since May 2024
Compare the behavior of semantic highlighting on the VS Code API (language client) and the LSP-based language server
For the semantic highlighting provided by the language client, when the order of the semantic tokens is inconsistent with the order of the tokens in the character stream, it can be highlighted correctly.
In the language server(implemented by Node.js based on the vscode-languageserver/node npm package), when the order is inconsistent, the highlighting is incorrect, and only tokens in increasing order are highlighted.

The code for providing semantic tokens between the language server and the client is almost exactly the same.

No requirement for the order of semantic tokens was found in the LSP documentation.
Is this a requirement for LSP? Or is it a bug in the vscode-languageserver/node npm package?
- Run
npm installin this folder. This installs all necessary npm modules in both the client and server folder - Open VS Code on this folder.
- Press Ctrl+Shift+B to start compiling the client and server in watch mode.
- Switch to the Run and Debug View in the Sidebar (Ctrl+Shift+D).
- Select
Launch Clientfrom the drop down (if it is not already). - Press ▷ to run the launch config (F5).
- If you want to debug the server as well, use the launch configuration
Attach to Server - In the Extension Development Host instance of VSCode
- Open the
examplefolder on this project's root. - Open
.clientHighlightand.serverHighlight
- Open the
.
├── client // Language Client
│ ├── src
│ │ └── extension.ts // Language Client entry point
├── package.json // The extension manifest.
└── server // Language Server
└── src
└── server.ts // Language Server entry point