From 9f3dbd6fa347559b07fe84293d5a74fb5d37dd14 Mon Sep 17 00:00:00 2001 From: "Andrew Borg (Kashin)" <1192958+aborg-dev@users.noreply.github.com> Date: Mon, 27 Jan 2025 15:10:39 +0000 Subject: [PATCH] Make ZED_WORKTREE_ROOT always point to a directory or is not set (#23150) When the out-of-tree file like `tasks.json` is-focus, tasks spawn with `ZED_WORKTREE_ROOT` unset. --- crates/project/src/task_inventory.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/project/src/task_inventory.rs b/crates/project/src/task_inventory.rs index 070a4d19aa..d67ad7f1ea 100644 --- a/crates/project/src/task_inventory.rs +++ b/crates/project/src/task_inventory.rs @@ -489,7 +489,7 @@ impl ContextProvider for BasicContextProvider { if !selected_text.trim().is_empty() { task_variables.insert(VariableName::SelectedText, selected_text); } - let worktree_abs_path = + let worktree_root_dir = buffer .file() .map(|file| file.worktree_id(cx)) @@ -497,9 +497,9 @@ impl ContextProvider for BasicContextProvider { self.worktree_store .read(cx) .worktree_for_id(worktree_id, cx) - .map(|worktree| worktree.read(cx).abs_path()) + .map(|worktree| worktree.read(cx).root_dir()) }); - if let Some(worktree_path) = worktree_abs_path { + if let Some(Some(worktree_path)) = worktree_root_dir { task_variables.insert( VariableName::WorktreeRoot, worktree_path.to_string_lossy().to_string(),