Allow to temporarily stop LSP servers (#28034)
Same as `editor::RestartLanguageServer`, now there's an `editor::StopLanguageServer` action that stops all language servers, related to the currently opened editor. Opening another singleton editor with the same language or changing selections in a multi buffer will bring the servers back up. Release Notes: - Added a way to temporarily stop LSP servers --------- Co-authored-by: Michael Sloan <mgsloan@gmail.com>
This commit is contained in:
co-authored by
Michael Sloan
parent
b9724d9cbe
commit
0c82541f0a
@@ -412,6 +412,7 @@ actions!(
|
||||
SortLinesCaseInsensitive,
|
||||
SortLinesCaseSensitive,
|
||||
SplitSelectionIntoLines,
|
||||
StopLanguageServer,
|
||||
SwitchSourceHeader,
|
||||
Tab,
|
||||
Backtab,
|
||||
|
||||
@@ -14149,6 +14149,25 @@ impl Editor {
|
||||
}
|
||||
}
|
||||
|
||||
fn stop_language_server(
|
||||
&mut self,
|
||||
_: &StopLanguageServer,
|
||||
_: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(project) = self.project.clone() {
|
||||
self.buffer.update(cx, |multi_buffer, cx| {
|
||||
project.update(cx, |project, cx| {
|
||||
project.stop_language_servers_for_buffers(
|
||||
multi_buffer.all_buffers().into_iter().collect(),
|
||||
cx,
|
||||
);
|
||||
cx.emit(project::Event::RefreshInlayHints);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn cancel_language_server_work(
|
||||
workspace: &mut Workspace,
|
||||
_: &actions::CancelLanguageServerWork,
|
||||
|
||||
@@ -452,6 +452,7 @@ impl EditorElement {
|
||||
}
|
||||
});
|
||||
register_action(editor, window, Editor::restart_language_server);
|
||||
register_action(editor, window, Editor::stop_language_server);
|
||||
register_action(editor, window, Editor::show_character_palette);
|
||||
register_action(editor, window, |editor, action, window, cx| {
|
||||
if let Some(task) = editor.confirm_completion(action, window, cx) {
|
||||
|
||||
Reference in New Issue
Block a user