-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZED_WORKTREE_ROOT should always point to a directory #22912
Comments
Fixes zed-industries#22912 Update `ZED_WORKTREE_ROOT` to always point to a directory. * **Documentation** - Add an example of correct usage of `ZED_WORKTREE_ROOT` in `docs/src/tasks.md`. * **Static Source** - Remove unnecessary comment in `crates/task/src/static_source.rs`. * **VSCode Format** - Add a test case in `crates/task/src/vscode_format.rs` to verify that `ZED_WORKTREE_ROOT` points to a directory. * **Tasks UI** - Modify the `task_context` function in `crates/tasks_ui/src/lib.rs` to ensure `ZED_WORKTREE_ROOT` points to a directory.
If no one is already working on this, I would love to try to implement this behavior. In my understanding we need to retrieve the worktree of the project that is opened in Zed and then use the newly created function Let me know if I missed something! [1] zed/crates/worktree/src/worktree.rs Line 2668 in 4445679
|
I've created the PR #23150 just to start the conversation about the desired behavior. In this first naive implementation, when the out-of-tree In my understanding, we want to return the root directory of the currently "active project". At the moment, Before I do this, though, can someone confirm that there is only one active project at a time? And are there plans for having more then one active project in the single Zed instance in the future? |
Detached files are a pretty gnarly edge case in general. |
Just to make sure I have all the terminology/assumptions correct:
Did I get it roughly right? In this case, it does seem like the concept of active project is well defined and it would be a reasonable target for newly spawned tasks.
Sure, I let me start with this to fix the immediate problem with |
Yeah, that's mostly correct except for the last point; they're hidden worktrees. Each worktree is a distinct top-level directory in a project panel and out-of-tree files are handled the same way, except that they're not shown in the UI. |
Check for existing issues
Describe the bug / provide steps to reproduce it
Steps to reproduce:
task: spawn
, selectzed env
at the bottom of the list.Documentation suggests this variable will point to a folder, which I believe makes sense:
zed/docs/src/tasks.md
Line 84 in 86f5bb1
Proposal: Behavior of
ZED_WORKTREE_ROOT
should match that default behavior ofcwd
which was improved in #22004 to not point at a file when spawned from a buffer that is outside of worktree (like the tasks.json example above).This makes it possible to spawn other applications into the correct working directory, even when that must be passed an argument, not just implicitly inherited from cwd/$PWD.
For example:
This does not work:
cd /tmp; alacritty
(working directory defaults to~
)This does work:
alacritty --working-directory=/tmp
Originally reported by @VOID404 here:
Zed Version and System Specs
Zed: v0.170.0 (Zed Nightly af1a3cb)
OS: macOS 14.7.0
Memory: 64 GiB
Architecture: aarch64
If applicable, add screenshots or screencasts of the incorrect state / behavior
No response
If applicable, attach your Zed.log file to this issue.
N/A
The text was updated successfully, but these errors were encountered: