Improve workspace bindings (#33765)
* Add a "close item"-like binding to close the active dock, if present Now, cmd/ctrl-w can be used close the focused dock before the Zed window * Add defaults to MoveItem* actions to make it appear in the command palette Release Notes: - N/A
This commit is contained in:
parent
64c413b9b6
commit
f27b508e4b
4 changed files with 28 additions and 4 deletions
|
@ -605,7 +605,9 @@
|
||||||
// "foo-bar": ["task::Spawn", { "task_name": "MyTask", "reveal_target": "dock" }]
|
// "foo-bar": ["task::Spawn", { "task_name": "MyTask", "reveal_target": "dock" }]
|
||||||
// or by tag:
|
// or by tag:
|
||||||
// "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }],
|
// "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }],
|
||||||
"f5": "debugger::Rerun"
|
"f5": "debugger::Rerun",
|
||||||
|
"ctrl-f4": "workspace::CloseActiveDock",
|
||||||
|
"ctrl-w": "workspace::CloseActiveDock"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -659,7 +659,8 @@
|
||||||
"cmd-k shift-up": "workspace::SwapPaneUp",
|
"cmd-k shift-up": "workspace::SwapPaneUp",
|
||||||
"cmd-k shift-down": "workspace::SwapPaneDown",
|
"cmd-k shift-down": "workspace::SwapPaneDown",
|
||||||
"cmd-shift-x": "zed::Extensions",
|
"cmd-shift-x": "zed::Extensions",
|
||||||
"f5": "debugger::Rerun"
|
"f5": "debugger::Rerun",
|
||||||
|
"cmd-w": "workspace::CloseActiveDock"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,6 +103,7 @@ pub struct ActivateItem(pub usize);
|
||||||
#[action(namespace = pane)]
|
#[action(namespace = pane)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CloseActiveItem {
|
pub struct CloseActiveItem {
|
||||||
|
#[serde(default)]
|
||||||
pub save_intent: Option<SaveIntent>,
|
pub save_intent: Option<SaveIntent>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub close_pinned: bool,
|
pub close_pinned: bool,
|
||||||
|
@ -112,6 +113,7 @@ pub struct CloseActiveItem {
|
||||||
#[action(namespace = pane)]
|
#[action(namespace = pane)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CloseInactiveItems {
|
pub struct CloseInactiveItems {
|
||||||
|
#[serde(default)]
|
||||||
pub save_intent: Option<SaveIntent>,
|
pub save_intent: Option<SaveIntent>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub close_pinned: bool,
|
pub close_pinned: bool,
|
||||||
|
@ -121,6 +123,7 @@ pub struct CloseInactiveItems {
|
||||||
#[action(namespace = pane)]
|
#[action(namespace = pane)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CloseAllItems {
|
pub struct CloseAllItems {
|
||||||
|
#[serde(default)]
|
||||||
pub save_intent: Option<SaveIntent>,
|
pub save_intent: Option<SaveIntent>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub close_pinned: bool,
|
pub close_pinned: bool,
|
||||||
|
|
|
@ -224,6 +224,7 @@ pub struct ActivatePane(pub usize);
|
||||||
#[action(namespace = workspace)]
|
#[action(namespace = workspace)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct MoveItemToPane {
|
pub struct MoveItemToPane {
|
||||||
|
#[serde(default = "default_1")]
|
||||||
pub destination: usize,
|
pub destination: usize,
|
||||||
#[serde(default = "default_true")]
|
#[serde(default = "default_true")]
|
||||||
pub focus: bool,
|
pub focus: bool,
|
||||||
|
@ -231,10 +232,15 @@ pub struct MoveItemToPane {
|
||||||
pub clone: bool,
|
pub clone: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_1() -> usize {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, PartialEq, JsonSchema, Action)]
|
#[derive(Clone, Deserialize, PartialEq, JsonSchema, Action)]
|
||||||
#[action(namespace = workspace)]
|
#[action(namespace = workspace)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct MoveItemToPaneInDirection {
|
pub struct MoveItemToPaneInDirection {
|
||||||
|
#[serde(default = "default_right")]
|
||||||
pub direction: SplitDirection,
|
pub direction: SplitDirection,
|
||||||
#[serde(default = "default_true")]
|
#[serde(default = "default_true")]
|
||||||
pub focus: bool,
|
pub focus: bool,
|
||||||
|
@ -242,10 +248,15 @@ pub struct MoveItemToPaneInDirection {
|
||||||
pub clone: bool,
|
pub clone: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_right() -> SplitDirection {
|
||||||
|
SplitDirection::Right
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Action)]
|
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Action)]
|
||||||
#[action(namespace = workspace)]
|
#[action(namespace = workspace)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct SaveAll {
|
pub struct SaveAll {
|
||||||
|
#[serde(default)]
|
||||||
pub save_intent: Option<SaveIntent>,
|
pub save_intent: Option<SaveIntent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +264,7 @@ pub struct SaveAll {
|
||||||
#[action(namespace = workspace)]
|
#[action(namespace = workspace)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Save {
|
pub struct Save {
|
||||||
|
#[serde(default)]
|
||||||
pub save_intent: Option<SaveIntent>,
|
pub save_intent: Option<SaveIntent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,6 +272,7 @@ pub struct Save {
|
||||||
#[action(namespace = workspace)]
|
#[action(namespace = workspace)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CloseAllItemsAndPanes {
|
pub struct CloseAllItemsAndPanes {
|
||||||
|
#[serde(default)]
|
||||||
pub save_intent: Option<SaveIntent>,
|
pub save_intent: Option<SaveIntent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,6 +280,7 @@ pub struct CloseAllItemsAndPanes {
|
||||||
#[action(namespace = workspace)]
|
#[action(namespace = workspace)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CloseInactiveTabsAndPanes {
|
pub struct CloseInactiveTabsAndPanes {
|
||||||
|
#[serde(default)]
|
||||||
pub save_intent: Option<SaveIntent>,
|
pub save_intent: Option<SaveIntent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2806,12 +2820,14 @@ impl Workspace {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close_active_dock(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn close_active_dock(&mut self, window: &mut Window, cx: &mut Context<Self>) -> bool {
|
||||||
if let Some(dock) = self.active_dock(window, cx) {
|
if let Some(dock) = self.active_dock(window, cx) {
|
||||||
dock.update(cx, |dock, cx| {
|
dock.update(cx, |dock, cx| {
|
||||||
dock.set_open(false, window, cx);
|
dock.set_open(false, window, cx);
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn close_all_docks(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
pub fn close_all_docks(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
|
@ -5450,7 +5466,9 @@ impl Workspace {
|
||||||
))
|
))
|
||||||
.on_action(cx.listener(
|
.on_action(cx.listener(
|
||||||
|workspace: &mut Workspace, _: &CloseActiveDock, window, cx| {
|
|workspace: &mut Workspace, _: &CloseActiveDock, window, cx| {
|
||||||
workspace.close_active_dock(window, cx);
|
if !workspace.close_active_dock(window, cx) {
|
||||||
|
cx.propagate();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
.on_action(
|
.on_action(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue