Replace pane::Split action with Split{Left,Up,Right,Down}

This allows us to show them in the command palette.
This commit is contained in:
Antonio Scandurra 2022-06-15 13:06:59 +02:00
parent fa942e6b3d
commit da1eb91935
3 changed files with 14 additions and 24 deletions

View file

@ -258,22 +258,10 @@
{ {
"context": "Pane", "context": "Pane",
"bindings": { "bindings": {
"cmd-k up": [ "cmd-k up": "pane::SplitUp",
"pane::Split", "cmd-k down": "pane::SplitDown",
"Up" "cmd-k left": "pane::SplitLeft",
], "cmd-k right": "pane::SplitRight"
"cmd-k down": [
"pane::Split",
"Down"
],
"cmd-k left": [
"pane::Split",
"Left"
],
"cmd-k right": [
"pane::Split",
"Right"
]
} }
}, },
// Bindings that should be unified with bindings for more general actions // Bindings that should be unified with bindings for more general actions

View file

@ -25,12 +25,13 @@ actions!(
ActivateNextItem, ActivateNextItem,
CloseActiveItem, CloseActiveItem,
CloseInactiveItems, CloseInactiveItems,
SplitLeft,
SplitUp,
SplitRight,
SplitDown,
] ]
); );
#[derive(Clone, Deserialize, PartialEq)]
pub struct Split(pub SplitDirection);
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
pub struct CloseItem { pub struct CloseItem {
pub item_id: usize, pub item_id: usize,
@ -52,7 +53,7 @@ pub struct GoForward {
pub pane: Option<WeakViewHandle<Pane>>, pub pane: Option<WeakViewHandle<Pane>>,
} }
impl_actions!(pane, [Split, GoBack, GoForward]); impl_actions!(pane, [GoBack, GoForward]);
impl_internal_actions!(pane, [CloseItem, ActivateItem]); impl_internal_actions!(pane, [CloseItem, ActivateItem]);
const MAX_NAVIGATION_HISTORY_LEN: usize = 1024; const MAX_NAVIGATION_HISTORY_LEN: usize = 1024;
@ -77,9 +78,10 @@ pub fn init(cx: &mut MutableAppContext) {
Ok(()) Ok(())
})) }))
}); });
cx.add_action(|pane: &mut Pane, action: &Split, cx| { cx.add_action(|pane: &mut Pane, _: &SplitLeft, cx| pane.split(SplitDirection::Left, cx));
pane.split(action.0, cx); cx.add_action(|pane: &mut Pane, _: &SplitUp, cx| pane.split(SplitDirection::Up, cx));
}); cx.add_action(|pane: &mut Pane, _: &SplitRight, cx| pane.split(SplitDirection::Right, cx));
cx.add_action(|pane: &mut Pane, _: &SplitDown, cx| pane.split(SplitDirection::Down, cx));
cx.add_action(|workspace: &mut Workspace, action: &GoBack, cx| { cx.add_action(|workspace: &mut Workspace, action: &GoBack, cx| {
Pane::go_back( Pane::go_back(
workspace, workspace,

View file

@ -948,7 +948,7 @@ mod tests {
(editor.downgrade(), buffer) (editor.downgrade(), buffer)
}); });
cx.dispatch_action(window_id, pane::Split(SplitDirection::Right)); cx.dispatch_action(window_id, pane::SplitRight);
let editor_2 = cx.update(|cx| { let editor_2 = cx.update(|cx| {
let pane_2 = workspace.read(cx).active_pane().clone(); let pane_2 = workspace.read(cx).active_pane().clone();
assert_ne!(pane_1, pane_2); assert_ne!(pane_1, pane_2);