Skip to content

Commit

Permalink
LSP: report that we use UTF-8 to client that supports it
Browse files Browse the repository at this point in the history
Version 3.17 of the spec added a `position_encoding` field in the
ServerCapabilities, so use that.

Note that the spec says that UTF-16 is mendatory, and vscode only
support utf-16, meaning we currently have a bug when having non-ascii in
the source (#5669)
  • Loading branch information
ogoffart committed Nov 8, 2024
1 parent fc01c54 commit 9cbc4aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/lsp/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ impl RequestHandler {
pub fn server_initialize_result(client_cap: &ClientCapabilities) -> InitializeResult {
InitializeResult {
capabilities: ServerCapabilities {
// Note: we only support UTF8 at the moment (which is a bug, as the spec says that support for utf-16 is mandatory)
position_encoding: client_cap
.general
.as_ref()
.and_then(|x| x.position_encodings.as_ref())
.and_then(|x| x.iter().find(|x| *x == &lsp_types::PositionEncodingKind::UTF8))
.cloned(),
hover_provider: Some(true.into()),
signature_help_provider: Some(lsp_types::SignatureHelpOptions {
trigger_characters: Some(vec!["(".to_owned(), ",".to_owned()]),
Expand Down

0 comments on commit 9cbc4aa

Please sign in to comment.