diff options
author | Philipp Mildenberger | 2023-03-27 19:21:42 +0000 |
---|---|---|
committer | Philipp Mildenberger | 2023-05-18 19:58:17 +0000 |
commit | 93fd79a949f0fcaa97fa30f841d90c6c1c3f68de (patch) | |
tree | b4514bb31d70580e112574bd745d150552a77d15 /helix-term | |
parent | 073000e54d862ef542387868c897d4f847fbe18a (diff) |
Remove offset_encoding in CodeActionOrCommandItem, as it can be retrieved on demand
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands/lsp.rs | 12 |
1 files 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<lsp::CodeActionResponse> = 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) => { |