diff --git a/crates/assistant/src/slash_command/file_command.rs b/crates/assistant/src/slash_command/file_command.rs index 3c3e7de9a62338..d0a9f072edbe11 100644 --- a/crates/assistant/src/slash_command/file_command.rs +++ b/crates/assistant/src/slash_command/file_command.rs @@ -293,7 +293,11 @@ fn collect_files( } else { let entry_name = format!("{}/{}", prefix_paths, &filename); output.text.push_str(&entry_name); - directory_stack.push((entry.relative_path.clone(), entry_name, entry_start)); + directory_stack.push(( + entry.relative_path.clone(), + entry_name, + entry_start, + )); } output.text.push('\n'); } else if entry.is_file() { diff --git a/crates/project/src/environment.rs b/crates/project/src/environment.rs index a0da43924ebc56..f9a74fcbe3a3d3 100644 --- a/crates/project/src/environment.rs +++ b/crates/project/src/environment.rs @@ -144,11 +144,11 @@ impl ProjectEnvironment { let load_direnv = ProjectSettings::get_global(cx).load_direnv.clone(); cx.spawn(|this, mut cx| async move { + let abs_path = worktree_abs_path.clone(); let (mut shell_env, error_message) = cx .background_executor() .spawn(async move { - load_shell_environment(worktree_abs_path.as_raw_path_buf(), &load_direnv) - .await + load_shell_environment(abs_path.as_raw_path_buf(), &load_direnv).await }) .await; diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 2b4aadcb38dd47..ce60283c775fd7 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -3128,7 +3128,7 @@ impl Project { abs_path: &SanitizedPathBuf, visible: bool, cx: &mut ModelContext, - ) -> Task, PathBuf)>> { + ) -> Task, SanitizedPathBuf)>> { self.worktree_store.update(cx, |worktree_store, cx| { worktree_store.find_or_create_worktree(abs_path, visible, cx) }) diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rs index 48346b5eb7423a..60e327bc86d19e 100644 --- a/crates/project/src/terminals.rs +++ b/crates/project/src/terminals.rs @@ -367,7 +367,7 @@ pub fn wrap_for_ssh( // shlex will wrap the command in single quotes (''), disabling ~ expansion, // replace ith with something that works let tilde_prefix = "~/"; - if path.starts_with(tilde_prefix) { + if path.as_trimmed_path_buf().starts_with(tilde_prefix) { let trimmed_path = path_string .trim_start_matches("/") .trim_start_matches("~") diff --git a/crates/project/src/worktree_store.rs b/crates/project/src/worktree_store.rs index f3561b8043f792..85b92871e83fbd 100644 --- a/crates/project/src/worktree_store.rs +++ b/crates/project/src/worktree_store.rs @@ -162,17 +162,16 @@ impl WorktreeStore { pub fn find_or_create_worktree( &mut self, - abs_path: impl AsRef, + abs_path: &SanitizedPathBuf, visible: bool, cx: &mut ModelContext, - ) -> Task, PathBuf)>> { - let abs_path = abs_path.as_ref(); + ) -> Task, SanitizedPathBuf)>> { if let Some((tree, relative_path)) = self.find_worktree(abs_path, cx) { Task::ready(Ok((tree, relative_path))) } else { let worktree = self.create_worktree(abs_path, visible, cx); cx.background_executor() - .spawn(async move { Ok((worktree.await?, PathBuf::new())) }) + .spawn(async move { Ok((worktree.await?, SanitizedPathBuf::new())) }) } } diff --git a/crates/recent_projects/src/dev_servers.rs b/crates/recent_projects/src/dev_servers.rs index 2c23261d7ceeab..15e43d01f2e22a 100644 --- a/crates/recent_projects/src/dev_servers.rs +++ b/crates/recent_projects/src/dev_servers.rs @@ -37,7 +37,6 @@ use ui::Scrollbar; use ui::ScrollbarState; use ui::Section; use ui::{prelude::*, IconButtonShape, List, ListItem, ListSeparator, Modal, ModalHeader, Tooltip}; -use util::paths::SanitizedPathBuf; use util::ResultExt; use workspace::notifications::NotificationId; use workspace::OpenOptions; @@ -244,6 +243,7 @@ impl ProjectPicker { let tasks = paths .into_iter() + .map(Into::into) .map(|path| { project.update(cx, |project, cx| { project.find_or_create_worktree(&path, true, cx) diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rs index e6eddac1d0eb5b..42acbee7792b9b 100644 --- a/crates/remote_server/src/headless_project.rs +++ b/crates/remote_server/src/headless_project.rs @@ -382,7 +382,7 @@ impl HeadlessProject { buffer_store.open_buffer( ProjectPath { worktree_id: worktree.read(cx).id(), - path: path.into(), + path: path.as_trimmed_path_buf().into(), }, cx, ) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index e9cf33f8c8b95d..00b06c1de8d36b 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -2736,7 +2736,11 @@ pub mod tests { assert!(a_dir_entry.is_dir()); window .update(cx, |workspace, cx| { - ProjectSearchView::new_search_in_directory(workspace, &a_dir_entry.relative_path, cx) + ProjectSearchView::new_search_in_directory( + workspace, + &a_dir_entry.relative_path, + cx, + ) }) .unwrap(); diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index 177a16d1d2648f..01b198e0afe4bd 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -1731,9 +1731,17 @@ fn randomly_mutate_worktree( Ok(()) }) } else { - log::info!("overwriting file {:?} ({})", entry.relative_path, entry.id.0); - let task = - worktree.write_file(entry.relative_path.clone(), "".into(), Default::default(), cx); + log::info!( + "overwriting file {:?} ({})", + entry.relative_path, + entry.id.0 + ); + let task = worktree.write_file( + entry.relative_path.clone(), + "".into(), + Default::default(), + cx, + ); cx.background_executor().spawn(async move { task.await?; Ok(())