mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Merge pull request #2094 from zed-industries/project-lost-window-close-action-shortcut-accessibility
Add "Close Window" global action which does not need a focused workspace
This commit is contained in:
commit
10f130ee30
2 changed files with 13 additions and 1 deletions
|
@ -875,7 +875,7 @@ impl MutableAppContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_ids(&self) -> impl Iterator<Item = usize> + '_ {
|
pub fn window_ids(&self) -> impl Iterator<Item = usize> + '_ {
|
||||||
self.cx.windows.keys().cloned()
|
self.cx.windows.keys().copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn activate_window(&self, window_id: usize) {
|
pub fn activate_window(&self, window_id: usize) {
|
||||||
|
|
|
@ -198,6 +198,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||||
cx.add_async_action(Workspace::toggle_follow);
|
cx.add_async_action(Workspace::toggle_follow);
|
||||||
cx.add_async_action(Workspace::follow_next_collaborator);
|
cx.add_async_action(Workspace::follow_next_collaborator);
|
||||||
cx.add_async_action(Workspace::close);
|
cx.add_async_action(Workspace::close);
|
||||||
|
cx.add_global_action(Workspace::close_global);
|
||||||
cx.add_async_action(Workspace::save_all);
|
cx.add_async_action(Workspace::save_all);
|
||||||
cx.add_action(Workspace::open_shared_screen);
|
cx.add_action(Workspace::open_shared_screen);
|
||||||
cx.add_action(Workspace::add_folder_to_project);
|
cx.add_action(Workspace::add_folder_to_project);
|
||||||
|
@ -823,6 +824,15 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn close_global(_: &CloseWindow, cx: &mut MutableAppContext) {
|
||||||
|
let id = cx.window_ids().find(|&id| cx.window_is_active(id));
|
||||||
|
if let Some(id) = id {
|
||||||
|
//This can only get called when the window's project connection has been lost
|
||||||
|
//so we don't need to prompt the user for anything and instead just close the window
|
||||||
|
cx.remove_window(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn close(
|
pub fn close(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &CloseWindow,
|
_: &CloseWindow,
|
||||||
|
@ -851,6 +861,7 @@ impl Workspace {
|
||||||
.window_ids()
|
.window_ids()
|
||||||
.flat_map(|window_id| cx.root_view::<Workspace>(window_id))
|
.flat_map(|window_id| cx.root_view::<Workspace>(window_id))
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
if let Some(active_call) = active_call {
|
if let Some(active_call) = active_call {
|
||||||
if !quitting
|
if !quitting
|
||||||
|
@ -866,6 +877,7 @@ impl Workspace {
|
||||||
)
|
)
|
||||||
.next()
|
.next()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if answer == Some(1) {
|
if answer == Some(1) {
|
||||||
return anyhow::Ok(false);
|
return anyhow::Ok(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue