mirror of https://github.com/helix-editor/helix
LSP: Use negotiated position encoding for workspace edits (#7469)
Previously this was hard-coded to UTF-8 but we might have negotiated another position encoding.pull/7488/head
parent
d3f8e0592b
commit
4fab60030f
|
@ -1047,9 +1047,12 @@ impl Application {
|
|||
Ok(serde_json::Value::Null)
|
||||
}
|
||||
Ok(MethodCall::ApplyWorkspaceEdit(params)) => {
|
||||
let language_server = language_server!();
|
||||
if language_server.is_initialized() {
|
||||
let offset_encoding = language_server.offset_encoding();
|
||||
let res = apply_workspace_edit(
|
||||
&mut self.editor,
|
||||
helix_lsp::OffsetEncoding::Utf8,
|
||||
offset_encoding,
|
||||
¶ms.edit,
|
||||
);
|
||||
|
||||
|
@ -1061,6 +1064,14 @@ impl Application {
|
|||
.err()
|
||||
.map(|err| err.failed_change_idx as u32),
|
||||
}))
|
||||
} else {
|
||||
Err(helix_lsp::jsonrpc::Error {
|
||||
code: helix_lsp::jsonrpc::ErrorCode::InvalidRequest,
|
||||
message: "Server must be initialized to request workspace edits"
|
||||
.to_string(),
|
||||
data: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
Ok(MethodCall::WorkspaceFolders) => {
|
||||
Ok(json!(&*language_server!().workspace_folders().await))
|
||||
|
|
Loading…
Reference in New Issue