Allow SplitAndMove on panes (#38034)

Updates #19350

Release Notes:

- Add `pane::SplitAndMove{Up,Down,Left,Right}` to allow creating a split
without cloning the current buffer.
This commit is contained in:
Conrad Irwin
2025-09-12 03:18:28 +00:00
committed by GitHub
parent ffb85d7e81
commit fcfc54c515
3 changed files with 118 additions and 19 deletions
+27 -2
View File
@@ -3929,8 +3929,15 @@ impl Workspace {
item: item.boxed_clone(),
});
}
pane::Event::Split(direction) => {
self.split_and_clone(pane.clone(), *direction, window, cx);
pane::Event::Split {
direction,
clone_active_item,
} => {
if *clone_active_item {
self.split_and_clone(pane.clone(), *direction, window, cx);
} else {
self.split_and_move(pane.clone(), *direction, window, cx);
}
}
pane::Event::JoinIntoNext => {
self.join_pane_into_next(pane.clone(), window, cx);
@@ -4044,6 +4051,24 @@ impl Workspace {
new_pane
}
pub fn split_and_move(
&mut self,
pane: Entity<Pane>,
direction: SplitDirection,
window: &mut Window,
cx: &mut Context<Self>,
) {
let Some(item) = pane.update(cx, |pane, cx| pane.take_active_item(window, cx)) else {
return;
};
let new_pane = self.add_pane(window, cx);
new_pane.update(cx, |pane, cx| {
pane.add_item(item, true, true, None, window, cx)
});
self.center.split(&pane, &new_pane, direction).unwrap();
cx.notify();
}
pub fn split_and_clone(
&mut self,
pane: Entity<Pane>,