Address some issues where panes don't get focused properly, make the focused pane more obvious, and prevent splitting of the pane with no items
This commit is contained in:
parent
d76cdb01be
commit
225055ed5d
13 changed files with 154 additions and 70 deletions
|
@ -1566,7 +1566,11 @@ impl Workspace {
|
|||
|
||||
fn activate_pane(&mut self, pane: ViewHandle<Pane>, cx: &mut ViewContext<Self>) {
|
||||
if self.active_pane != pane {
|
||||
self.active_pane
|
||||
.update(cx, |pane, cx| pane.set_active(false, cx));
|
||||
self.active_pane = pane.clone();
|
||||
self.active_pane
|
||||
.update(cx, |pane, cx| pane.set_active(true, cx));
|
||||
self.status_bar.update(cx, |status_bar, cx| {
|
||||
status_bar.set_active_pane(&self.active_pane, cx);
|
||||
});
|
||||
|
@ -1629,17 +1633,17 @@ impl Workspace {
|
|||
pane: ViewHandle<Pane>,
|
||||
direction: SplitDirection,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> ViewHandle<Pane> {
|
||||
let new_pane = self.add_pane(cx);
|
||||
self.activate_pane(new_pane.clone(), cx);
|
||||
if let Some(item) = pane.read(cx).active_item() {
|
||||
) -> Option<ViewHandle<Pane>> {
|
||||
pane.read(cx).active_item().map(|item| {
|
||||
let new_pane = self.add_pane(cx);
|
||||
self.activate_pane(new_pane.clone(), cx);
|
||||
if let Some(clone) = item.clone_on_split(cx.as_mut()) {
|
||||
Pane::add_item(self, new_pane.clone(), clone, true, true, cx);
|
||||
}
|
||||
}
|
||||
self.center.split(&pane, &new_pane, direction).unwrap();
|
||||
cx.notify();
|
||||
new_pane
|
||||
self.center.split(&pane, &new_pane, direction).unwrap();
|
||||
cx.notify();
|
||||
new_pane
|
||||
})
|
||||
}
|
||||
|
||||
fn remove_pane(&mut self, pane: ViewHandle<Pane>, cx: &mut ViewContext<Self>) {
|
||||
|
@ -3045,7 +3049,9 @@ mod tests {
|
|||
// multi-entry items: (3, 4)
|
||||
let left_pane = workspace.update(cx, |workspace, cx| {
|
||||
let left_pane = workspace.active_pane().clone();
|
||||
let right_pane = workspace.split_pane(left_pane.clone(), SplitDirection::Right, cx);
|
||||
let right_pane = workspace
|
||||
.split_pane(left_pane.clone(), SplitDirection::Right, cx)
|
||||
.unwrap();
|
||||
|
||||
workspace.activate_pane(left_pane.clone(), cx);
|
||||
workspace.add_item(Box::new(cx.add_view(|_| item_2_3.clone())), cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue