Allow running cancel-language-server-work action w/o editor focused (#24215)

Release Notes:

- Added the ability to run the `cancel language server work` action
while a panel (like the terminal panel) is focused
This commit is contained in:
Max Brunsfeld 2025-02-04 12:49:08 -08:00 committed by GitHub
parent 5704b50fb1
commit 6f0f9d631e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 10 deletions

View file

@ -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(

View file

@ -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) {