diff --git a/crates/journal/src/journal.rs b/crates/journal/src/journal.rs index a1236297ed1e3f0af70ddc557994087304493c7c..a1620664c6342fcb45df78e0d8ff8487272b2b1c 100644 --- a/crates/journal/src/journal.rs +++ b/crates/journal/src/journal.rs @@ -100,7 +100,7 @@ pub fn new_journal_entry(app_state: Arc, cx: &mut WindowContext) { let opened = workspace .update(&mut cx, |workspace, cx| { - workspace.open_paths(vec![entry_path], true, cx) + workspace.open_paths(vec![entry_path], true, None, cx) })? .await; diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index d519523974f7a63ee210cd4cb4e2c1c06f2da8db..d788a1b62771c29560afa782a91d3f741a50a4ce 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -197,7 +197,7 @@ impl TerminalView { cx.spawn(|_, mut cx| async move { let opened_items = task_workspace .update(&mut cx, |workspace, cx| { - workspace.open_paths(vec![path.path_like], is_dir, cx) + workspace.open_paths(vec![path.path_like], is_dir, None, cx) }) .context("workspace update")? .await; diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 1798112fcc1f28655225d86fb349bb0446463170..fe41d0f8b2b38c673ddc6a4790f845ad65bd8b1b 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1869,28 +1869,21 @@ impl Pane { paths: &ExternalPaths, cx: &mut ViewContext<'_, Pane>, ) { - // let mut to_pane = cx.view().clone(); - // let split_direction = self.drag_split_direction; - // let project_entry_id = *project_entry_id; - // self.workspace - // .update(cx, |_, cx| { - // cx.defer(move |workspace, cx| { - // if let Some(path) = workspace - // .project() - // .read(cx) - // .path_for_entry(project_entry_id, cx) - // { - // if let Some(split_direction) = split_direction { - // to_pane = workspace.split_pane(to_pane, split_direction, cx); - // } - // workspace - // .open_path(path, Some(to_pane.downgrade()), true, cx) - // .detach_and_log_err(cx); - // } - // }); - // }) - // .log_err(); - dbg!("@@@@@@@@@@@@@@", paths); + let mut to_pane = cx.view().clone(); + let split_direction = self.drag_split_direction; + let paths = paths.paths().to_vec(); + self.workspace + .update(cx, |_, cx| { + cx.defer(move |workspace, cx| { + if let Some(split_direction) = split_direction { + to_pane = workspace.split_pane(to_pane, split_direction, cx); + } + workspace + .open_paths(paths, true, Some(to_pane.downgrade()), cx) + .detach(); + }); + }) + .log_err(); } pub fn display_nav_history_buttons(&mut self, display: bool) { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 78595d2c3126845cc06d5c14cc5e51084334d65e..f23dfca85754be24fd8792b3975a927b0ee4d331 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1322,6 +1322,7 @@ impl Workspace { &mut self, mut abs_paths: Vec, visible: bool, + pane: Option>, cx: &mut ViewContext, ) -> Task, anyhow::Error>>>> { log::info!("open paths {abs_paths:?}"); @@ -1351,12 +1352,13 @@ impl Workspace { let this = this.clone(); let abs_path = abs_path.clone(); let fs = fs.clone(); + let pane = pane.clone(); let task = cx.spawn(move |mut cx| async move { let (worktree, project_path) = project_path?; if fs.is_file(&abs_path).await { Some( this.update(&mut cx, |this, cx| { - this.open_path(project_path, None, true, cx) + this.open_path(project_path, pane, true, cx) }) .log_err()? .await, @@ -1402,7 +1404,7 @@ impl Workspace { cx.spawn(|this, mut cx| async move { if let Some(paths) = paths.await.log_err().flatten() { let results = this - .update(&mut cx, |this, cx| this.open_paths(paths, true, cx))? + .update(&mut cx, |this, cx| this.open_paths(paths, true, None, cx))? .await; for result in results.into_iter().flatten() { result.log_err(); @@ -1788,7 +1790,7 @@ impl Workspace { cx.spawn(|workspace, mut cx| async move { let open_paths_task_result = workspace .update(&mut cx, |workspace, cx| { - workspace.open_paths(vec![abs_path.clone()], visible, cx) + workspace.open_paths(vec![abs_path.clone()], visible, None, cx) }) .with_context(|| format!("open abs path {abs_path:?} task spawn"))? .await; @@ -4087,7 +4089,7 @@ pub fn open_paths( existing.clone(), existing .update(&mut cx, |workspace, cx| { - workspace.open_paths(abs_paths, true, cx) + workspace.open_paths(abs_paths, true, None, cx) })? .await, )) @@ -4135,7 +4137,7 @@ pub fn create_and_open_local_file( let mut items = workspace .update(&mut cx, |workspace, cx| { workspace.with_local_workspace(cx, |workspace, cx| { - workspace.open_paths(vec![path.to_path_buf()], false, cx) + workspace.open_paths(vec![path.to_path_buf()], false, None, cx) }) })? .await?