From 852fb5152869f31a9bc96bdd7459135f2ea2d1cd Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 22 Nov 2024 09:20:49 -0700 Subject: [PATCH] Canonicalize paths when opening workspaces (#21039) Closes #17161 Release Notes: - Added symlink resolution when opening projects from within Zed. Previously this only happened within zed's cli, but that broke file watching on Linux when opening a symlinked directory. --- crates/workspace/src/workspace.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 32e441ee50692a7ea3ef732834ba2a3242c1ea4b..45de7815776b698f41c6cbd05a75ea5963716307 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1096,10 +1096,17 @@ impl Workspace { ); cx.spawn(|mut cx| async move { - let serialized_workspace: Option = - persistence::DB.workspace_for_roots(abs_paths.as_slice()); + let mut paths_to_open = Vec::with_capacity(abs_paths.len()); + for path in abs_paths.into_iter() { + if let Some(canonical) = app_state.fs.canonicalize(&path).await.ok() { + paths_to_open.push(canonical) + } else { + paths_to_open.push(path) + } + } - let mut paths_to_open = abs_paths; + let serialized_workspace: Option = + persistence::DB.workspace_for_roots(paths_to_open.as_slice()); let workspace_location = serialized_workspace .as_ref()