microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.78k stars 28.73k forks source link

Only sends a `textDocument/documentHighlight` request when on an identifier #127007

Open Veykril opened 3 years ago

Veykril commented 3 years ago

Does this issue occur when all extensions are disabled?: Yes

VSCode doesn't seem to send a textDocument/documentHighlight request when the cursor isn't on an identifier(whatever this means to vscode). The LSP documentation doesn't state that this request should only be sent in that case though.

The document highlight request is sent from the client to the server to resolve a document highlights for a given text document position. https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight

We ran into this in rust-analyzer when trying to highlight exit points, which in rust can have the form of a simple ? character. So having the cursor on this character currently can't trigger the highlight. https://github.com/rust-analyzer/rust-analyzer/pull/9375

mohe2015 commented 1 year ago

In my opinion this is not a feature request but a bug. I also ran into this and it seems like it isn't even based on the semantic tokens but instead does random stuff on e.g. quote and paren characters. Therefore it seems like a workaround is not too easy.