diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index f0ed829c1e..6f50945828 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -605,7 +605,9 @@ // "foo-bar": ["task::Spawn", { "task_name": "MyTask", "reveal_target": "dock" }] // or by tag: // "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }], - "f5": "debugger::Rerun" + "f5": "debugger::Rerun", + "ctrl-f4": "workspace::CloseActiveDock", + "ctrl-w": "workspace::CloseActiveDock" } }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index cd986e12e9..71b7a39789 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -659,7 +659,8 @@ "cmd-k shift-up": "workspace::SwapPaneUp", "cmd-k shift-down": "workspace::SwapPaneDown", "cmd-shift-x": "zed::Extensions", - "f5": "debugger::Rerun" + "f5": "debugger::Rerun", + "cmd-w": "workspace::CloseActiveDock" } }, { diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index cb2dd99f5e..b002d3ebe7 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -103,6 +103,7 @@ pub struct ActivateItem(pub usize); #[action(namespace = pane)] #[serde(deny_unknown_fields)] pub struct CloseActiveItem { + #[serde(default)] pub save_intent: Option, #[serde(default)] pub close_pinned: bool, @@ -112,6 +113,7 @@ pub struct CloseActiveItem { #[action(namespace = pane)] #[serde(deny_unknown_fields)] pub struct CloseInactiveItems { + #[serde(default)] pub save_intent: Option, #[serde(default)] pub close_pinned: bool, @@ -121,6 +123,7 @@ pub struct CloseInactiveItems { #[action(namespace = pane)] #[serde(deny_unknown_fields)] pub struct CloseAllItems { + #[serde(default)] pub save_intent: Option, #[serde(default)] pub close_pinned: bool, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index d31a7831ee..95e0a4aa68 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -224,6 +224,7 @@ pub struct ActivatePane(pub usize); #[action(namespace = workspace)] #[serde(deny_unknown_fields)] pub struct MoveItemToPane { + #[serde(default = "default_1")] pub destination: usize, #[serde(default = "default_true")] pub focus: bool, @@ -231,10 +232,15 @@ pub struct MoveItemToPane { pub clone: bool, } +fn default_1() -> usize { + 1 +} + #[derive(Clone, Deserialize, PartialEq, JsonSchema, Action)] #[action(namespace = workspace)] #[serde(deny_unknown_fields)] pub struct MoveItemToPaneInDirection { + #[serde(default = "default_right")] pub direction: SplitDirection, #[serde(default = "default_true")] pub focus: bool, @@ -242,10 +248,15 @@ pub struct MoveItemToPaneInDirection { pub clone: bool, } +fn default_right() -> SplitDirection { + SplitDirection::Right +} + #[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = workspace)] #[serde(deny_unknown_fields)] pub struct SaveAll { + #[serde(default)] pub save_intent: Option, } @@ -253,6 +264,7 @@ pub struct SaveAll { #[action(namespace = workspace)] #[serde(deny_unknown_fields)] pub struct Save { + #[serde(default)] pub save_intent: Option, } @@ -260,6 +272,7 @@ pub struct Save { #[action(namespace = workspace)] #[serde(deny_unknown_fields)] pub struct CloseAllItemsAndPanes { + #[serde(default)] pub save_intent: Option, } @@ -267,6 +280,7 @@ pub struct CloseAllItemsAndPanes { #[action(namespace = workspace)] #[serde(deny_unknown_fields)] pub struct CloseInactiveTabsAndPanes { + #[serde(default)] pub save_intent: Option, } @@ -2806,12 +2820,14 @@ impl Workspace { }) } - fn close_active_dock(&mut self, window: &mut Window, cx: &mut Context) { + fn close_active_dock(&mut self, window: &mut Window, cx: &mut Context) -> bool { if let Some(dock) = self.active_dock(window, cx) { dock.update(cx, |dock, cx| { dock.set_open(false, window, cx); }); + return true; } + false } pub fn close_all_docks(&mut self, window: &mut Window, cx: &mut Context) { @@ -5450,7 +5466,9 @@ impl Workspace { )) .on_action(cx.listener( |workspace: &mut Workspace, _: &CloseActiveDock, window, cx| { - workspace.close_active_dock(window, cx); + if !workspace.close_active_dock(window, cx) { + cx.propagate(); + } }, )) .on_action(