From 93fd79a949f0fcaa97fa30f841d90c6c1c3f68de Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Mon, 27 Mar 2023 21:21:42 +0200 Subject: Remove offset_encoding in CodeActionOrCommandItem, as it can be retrieved on demand --- helix-term/src/commands/lsp.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index 15f8d93d..38ba98d4 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -535,7 +535,6 @@ pub fn workspace_diagnostics_picker(cx: &mut Context) { struct CodeActionOrCommandItem { lsp_item: lsp::CodeActionOrCommand, - offset_encoding: OffsetEncoding, language_server_id: usize, } @@ -637,9 +636,9 @@ pub fn code_action(cx: &mut Context) { }; let code_action_request = language_server.code_actions(doc.identifier(), range, code_action_context)?; - Some((code_action_request, offset_encoding, language_server_id)) + Some((code_action_request, language_server_id)) }) - .map(|(request, offset_encoding, ls_id)| async move { + .map(|(request, ls_id)| async move { let json = request.await?; let response: Option = serde_json::from_value(json)?; let mut actions = match response { @@ -695,7 +694,6 @@ pub fn code_action(cx: &mut Context) { .into_iter() .map(|lsp_item| CodeActionOrCommandItem { lsp_item, - offset_encoding, language_server_id: ls_id, }) .collect()) @@ -727,7 +725,11 @@ pub fn code_action(cx: &mut Context) { // always present here let action = action.unwrap(); - let offset_encoding = action.offset_encoding; + let Some(language_server) = editor.language_servers.get_by_id(action.language_server_id) else { + editor.set_error("Language Server disappeared"); + return; + }; + let offset_encoding = language_server.offset_encoding(); match &action.lsp_item { lsp::CodeActionOrCommand::Command(command) => { -- cgit v1.2.3-70-g09d2