mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 19:02:07 +00:00
Activate previous pane and next pane via cmd-k cmd-left
and cmd-k cmd-right
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
097bbe3e07
commit
edc038a1cf
1 changed files with 24 additions and 0 deletions
|
@ -78,6 +78,8 @@ action!(Unfollow);
|
|||
action!(JoinProject, JoinProjectParams);
|
||||
action!(Save);
|
||||
action!(DebugElements);
|
||||
action!(ActivatePreviousPane);
|
||||
action!(ActivateNextPane);
|
||||
|
||||
pub fn init(client: &Arc<Client>, cx: &mut MutableAppContext) {
|
||||
pane::init(cx);
|
||||
|
@ -111,10 +113,18 @@ pub fn init(client: &Arc<Client>, cx: &mut MutableAppContext) {
|
|||
cx.add_action(Workspace::debug_elements);
|
||||
cx.add_action(Workspace::toggle_sidebar_item);
|
||||
cx.add_action(Workspace::toggle_sidebar_item_focus);
|
||||
cx.add_action(|workspace: &mut Workspace, _: &ActivatePreviousPane, cx| {
|
||||
workspace.activate_previous_pane(cx)
|
||||
});
|
||||
cx.add_action(|workspace: &mut Workspace, _: &ActivateNextPane, cx| {
|
||||
workspace.activate_next_pane(cx)
|
||||
});
|
||||
cx.add_bindings(vec![
|
||||
Binding::new("ctrl-alt-cmd-f", FollowNextCollaborator, None),
|
||||
Binding::new("cmd-s", Save, None),
|
||||
Binding::new("cmd-alt-i", DebugElements, None),
|
||||
Binding::new("cmd-k cmd-left", ActivatePreviousPane, None),
|
||||
Binding::new("cmd-k cmd-right", ActivateNextPane, None),
|
||||
Binding::new(
|
||||
"cmd-shift-!",
|
||||
ToggleSidebarItem(SidebarItemId {
|
||||
|
@ -1159,6 +1169,20 @@ impl Workspace {
|
|||
self.activate_pane(self.panes[next_ix].clone(), cx);
|
||||
}
|
||||
|
||||
pub fn activate_previous_pane(&mut self, cx: &mut ViewContext<Self>) {
|
||||
let ix = self
|
||||
.panes
|
||||
.iter()
|
||||
.position(|pane| pane == &self.active_pane)
|
||||
.unwrap();
|
||||
let prev_ix = if ix == 0 {
|
||||
self.panes.len() - 1
|
||||
} else {
|
||||
ix - 1
|
||||
};
|
||||
self.activate_pane(self.panes[prev_ix].clone(), cx);
|
||||
}
|
||||
|
||||
fn activate_pane(&mut self, pane: ViewHandle<Pane>, cx: &mut ViewContext<Self>) {
|
||||
if self.active_pane != pane {
|
||||
self.active_pane = pane.clone();
|
||||
|
|
Loading…
Reference in a new issue