Cycle through panes spatially rather than in the order in which they created
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
5ac39aa7cd
commit
60b6b0b317
2 changed files with 36 additions and 17 deletions
|
@ -57,6 +57,12 @@ impl PaneGroup {
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
self.root.render(theme, follower_states, collaborators)
|
self.root.render(theme, follower_states, collaborators)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn panes(&self) -> Vec<&ViewHandle<Pane>> {
|
||||||
|
let mut panes = Vec::new();
|
||||||
|
self.root.collect_panes(&mut panes);
|
||||||
|
panes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
@ -122,6 +128,17 @@ impl Member {
|
||||||
Member::Axis(axis) => axis.render(theme, follower_states, collaborators),
|
Member::Axis(axis) => axis.render(theme, follower_states, collaborators),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn collect_panes<'a>(&'a self, panes: &mut Vec<&'a ViewHandle<Pane>>) {
|
||||||
|
match self {
|
||||||
|
Member::Axis(axis) => {
|
||||||
|
for member in &axis.members {
|
||||||
|
member.collect_panes(panes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Member::Pane(pane) => panes.push(pane),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
|
|
@ -1160,27 +1160,29 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn activate_next_pane(&mut self, cx: &mut ViewContext<Self>) {
|
pub fn activate_next_pane(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
let ix = self
|
let next_pane = {
|
||||||
.panes
|
let panes = self.center.panes();
|
||||||
.iter()
|
let ix = panes
|
||||||
.position(|pane| pane == &self.active_pane)
|
.iter()
|
||||||
.unwrap();
|
.position(|pane| **pane == self.active_pane)
|
||||||
let next_ix = (ix + 1) % self.panes.len();
|
.unwrap();
|
||||||
self.activate_pane(self.panes[next_ix].clone(), cx);
|
let next_ix = (ix + 1) % panes.len();
|
||||||
|
panes[next_ix].clone()
|
||||||
|
};
|
||||||
|
self.activate_pane(next_pane, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn activate_previous_pane(&mut self, cx: &mut ViewContext<Self>) {
|
pub fn activate_previous_pane(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
let ix = self
|
let prev_pane = {
|
||||||
.panes
|
let panes = self.center.panes();
|
||||||
.iter()
|
let ix = panes
|
||||||
.position(|pane| pane == &self.active_pane)
|
.iter()
|
||||||
.unwrap();
|
.position(|pane| **pane == self.active_pane)
|
||||||
let prev_ix = if ix == 0 {
|
.unwrap();
|
||||||
self.panes.len() - 1
|
let prev_ix = if ix == 0 { panes.len() - 1 } else { ix - 1 };
|
||||||
} else {
|
panes[prev_ix].clone()
|
||||||
ix - 1
|
|
||||||
};
|
};
|
||||||
self.activate_pane(self.panes[prev_ix].clone(), cx);
|
self.activate_pane(prev_pane, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activate_pane(&mut self, pane: ViewHandle<Pane>, cx: &mut ViewContext<Self>) {
|
fn activate_pane(&mut self, pane: ViewHandle<Pane>, cx: &mut ViewContext<Self>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue