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
+23 -21
View File
@@ -38,7 +38,7 @@ use ui::{
prelude::*,
scrollbars::{self, GlobalSetting, ScrollbarVisibility},
};
use util::ResultExt;
use util::{ResultExt, maybe};
use workspace::{
CloseActiveItem, NewCenterTerminal, NewTerminal, ToolbarItemLocation, Workspace, WorkspaceId,
delete_unloaded_items,
@@ -1218,27 +1218,29 @@ impl Item for TerminalView {
workspace_id: Option<WorkspaceId>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>> {
let terminal = self
.project
.update(cx, |project, cx| {
let cwd = project
.active_project_directory(cx)
.map(|it| it.to_path_buf());
project.clone_terminal(self.terminal(), cx, cwd)
})
.ok()?
.log_err()?;
) -> Task<Option<Entity<Self>>> {
Task::ready(maybe!({
let terminal = self
.project
.update(cx, |project, cx| {
let cwd = project
.active_project_directory(cx)
.map(|it| it.to_path_buf());
project.clone_terminal(self.terminal(), cx, cwd)
})
.ok()?
.log_err()?;
Some(cx.new(|cx| {
TerminalView::new(
terminal,
self.workspace.clone(),
workspace_id,
self.project.clone(),
window,
cx,
)
Some(cx.new(|cx| {
TerminalView::new(
terminal,
self.workspace.clone(),
workspace_id,
self.project.clone(),
window,
cx,
)
}))
}))
}