Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Allow running cancel-language-server-work action w/o editor focused (#24215)
Max Brunsfeld6f0f9d631e14
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 63f0068eda8..05337a0f5ad 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -306,6 +306,7 @@ pub fn init(cx: &mut App) {workspace.register_action(Editor::new_file);workspace.register_action(Editor::new_file_vertical);workspace.register_action(Editor::new_file_horizontal);+ workspace.register_action(Editor::cancel_language_server_work);},).detach();@@ -11306,18 +11307,21 @@ impl Editor {}fn cancel_language_server_work(- &mut self,+ workspace: &mut Workspace,_: &actions::CancelLanguageServerWork,_: &mut Window,- cx: &mut Context<Self>,+ cx: &mut Context<Workspace>,) {- if let Some(project) = self.project.clone() {- self.buffer.update(cx, |multi_buffer, cx| {- project.update(cx, |project, cx| {- project.cancel_language_server_work_for_buffers(multi_buffer.all_buffers(), cx);- });- })- }+ let project = workspace.project();+ let buffers = workspace+ .active_item(cx)+ .and_then(|item| item.act_as::<Editor>(cx))+ .map_or(HashSet::default(), |editor| {+ editor.read(cx).buffer.read(cx).all_buffers()+ });+ project.update(cx, |project, cx| {+ project.cancel_language_server_work_for_buffers(buffers, cx);+ });}fn show_character_palette(diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 632c81c6b14..af6339cd687 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -430,7 +430,6 @@ impl EditorElement {}});register_action(editor, window, Editor::restart_language_server);- register_action(editor, window, Editor::cancel_language_server_work);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) {