summaryrefslogtreecommitdiff
path: root/helix-term/src/commands/lsp.rs
diff options
context:
space:
mode:
authorPhilipp Mildenberger2023-04-05 16:50:05 +0000
committerPhilipp Mildenberger2023-05-18 20:04:47 +0000
commit39b9a4bba2a026844348886c9d9f2026a3d6f658 (patch)
tree5d940e2692d13faf949606aa5bb13267dad48547 /helix-term/src/commands/lsp.rs
parent521cdec5a1a53c61d38ce5a1df85f82857f59149 (diff)
Add function `Editor::language_server_by_id` and refactor/simplify related code, also don't 'crash' in completion menu if language_server somehow disappeared
Diffstat (limited to 'helix-term/src/commands/lsp.rs')
-rw-r--r--helix-term/src/commands/lsp.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 38ba98d4..f7d35873 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -301,7 +301,7 @@ fn diag_picker(
flat_diag.reserve(diags.len());
for (diag, ls) in diags {
- if let Some(ls) = cx.editor.language_servers.get_by_id(ls) {
+ if let Some(ls) = cx.editor.language_server_by_id(ls) {
flat_diag.push(PickerDiagnostic {
url: url.clone(),
diag,
@@ -725,7 +725,7 @@ pub fn code_action(cx: &mut Context) {
// always present here
let action = action.unwrap();
- let Some(language_server) = editor.language_servers.get_by_id(action.language_server_id) else {
+ let Some(language_server) = editor.language_server_by_id(action.language_server_id) else {
editor.set_error("Language Server disappeared");
return;
};
@@ -772,8 +772,7 @@ pub fn execute_lsp_command(editor: &mut Editor, language_server_id: usize, cmd:
// the command is executed on the server and communicated back
// to the client asynchronously using workspace edits
let future = match editor
- .language_servers
- .get_by_id(language_server_id)
+ .language_server_by_id(language_server_id)
.and_then(|language_server| language_server.command(cmd))
{
Some(future) => future,