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.
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user