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:
+14
-6
@@ -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,
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user