workspace: Make Item::clone_on_split async (#41211)

Split out from https://github.com/zed-industries/zed/pull/40774 to
reduce the size of the reland of that PR (once I figure out the cause of
the issue)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-26 08:46:37 +00:00
committed by GitHub
parent b7cc597d28
commit 33ec545d1f
24 changed files with 217 additions and 157 deletions
+14 -6
View File
@@ -2854,14 +2854,16 @@ mod tests {
});
// Split the pane with the first entry, then open the second entry again.
window
let (task1, task2) = window
.update(cx, |w, window, cx| {
w.split_and_clone(w.active_pane().clone(), SplitDirection::Right, window, cx);
w.open_path(file2.clone(), None, true, window, cx)
(
w.split_and_clone(w.active_pane().clone(), SplitDirection::Right, window, cx),
w.open_path(file2.clone(), None, true, window, cx),
)
})
.unwrap()
.await
.unwrap();
task1.await.unwrap();
task2.await.unwrap();
window
.read_with(cx, |w, cx| {
@@ -3484,7 +3486,13 @@ mod tests {
SplitDirection::Right,
window,
cx,
);
)
})
.unwrap()
.await
.unwrap();
window
.update(cx, |workspace, window, cx| {
workspace.open_path(
(worktree.read(cx).id(), rel_path("the-new-name.rs")),
None,
+3 -3
View File
@@ -720,7 +720,7 @@ impl Item for ComponentPreview {
_workspace_id: Option<WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<gpui::Entity<Self>>
) -> Task<Option<gpui::Entity<Self>>>
where
Self: Sized,
{
@@ -742,13 +742,13 @@ impl Item for ComponentPreview {
cx,
);
match self_result {
Task::ready(match self_result {
Ok(preview) => Some(cx.new(|_cx| preview)),
Err(e) => {
log::error!("Failed to clone component preview: {}", e);
None
}
}
})
}
fn to_item_events(event: &Self::Event, mut f: impl FnMut(workspace::item::ItemEvent)) {