From 39b9a4bba2a026844348886c9d9f2026a3d6f658 Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Wed, 5 Apr 2023 18:50:05 +0200 Subject: Add function `Editor::language_server_by_id` and refactor/simplify related code, also don't 'crash' in completion menu if language_server somehow disappeared --- helix-view/src/editor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'helix-view/src') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index ca2144fd..afb8d91f 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -874,7 +874,7 @@ pub struct Editor { /// times during rendering and should not be set by other functions. pub cursor_cache: Cell>>, /// When a new completion request is sent to the server old - /// unifinished request must be dropped. Each completion + /// unfinished request must be dropped. Each completion /// request is associated with a channel that cancels /// when the channel is dropped. That channel is stored /// here. When a new completion request is sent this @@ -1093,6 +1093,11 @@ impl Editor { self._refresh(); } + #[inline] + pub fn language_server_by_id(&self, language_server_id: usize) -> Option<&helix_lsp::Client> { + self.language_servers.get_by_id(language_server_id) + } + /// Refreshes the language server for a given document pub fn refresh_language_servers(&mut self, doc_id: DocumentId) -> Option<()> { self.launch_language_servers(doc_id) -- cgit v1.2.3-70-g09d2