From 530feb6d721ae3b064c58cf5437f6a25515fdb6c Mon Sep 17 00:00:00 2001 From: dino Date: Tue, 2 Jun 2026 15:25:26 +0100 Subject: [PATCH] fix(fs): avoid resolving symlinks when trashing Use `std::path::absolute` instead of `RealFs::canonicalize` to make the path absolute in `RealFs::trash` as `canonicalize` also resolves symlinks, so trashing a symlink moved its target to the trash and left the link dangling. --- crates/fs/src/fs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 7809e65eeb32d4..ce1798a73ccfe5 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -802,10 +802,10 @@ impl Fs for RealFs { // We must make the path absolute or trash will make a weird abomination // of the zed working directory (not usually the worktree) and whatever // the path variable holds. - let path = self - .canonicalize(path) - .await - .context("Could not canonicalize the path of the file")?; + // We deliberately use `std::path::absolute` instead of `canonicalize` + // to avoid resolving symlinks. Otherwise trashing a symlink would trash + // its target and leave the link behind. + let path = std::path::absolute(path).context("Could not make the path absolute")?; let (tx, rx) = futures::channel::oneshot::channel(); std::thread::Builder::new()