terminal_view: Fix terminal opening in / when no project is open (#46582) (cherry-pick to preview)#46682
Merged
zed-zippy[bot] merged 1 commit intov0.219.xfrom Jan 13, 2026
Merged
Conversation
) Closes #46574 The `default_working_directory()` function in `crates/terminal_view/src/terminal_view.rs:1585` returned `None` when no project directory was available. The code comment (now removed) incorrectly claimed "None implies `~` on whichever machine we end up on". However, when `None` is passed to `alacritty_terminal`, it uses the process CWD, not the home directory. On macOS when Zed is launched from a .`app` bundle, the CWD is `/`. Added a fallback at the end of` default_working_directory()` that explicitly returns the home directory when no project directory is found: `directory.or_else(dirs::home_dir)` This ensures: 1. `CurrentProjectDirectory` with no project open → home directory 2. `FirstProjectDirectory `with no project open → home directory 3. `AlwaysHome `→ home directory (explicitly, not relying on shell behavior) 4. Always `{ directory }` with invalid directory → home directory Release Notes: - Fixed terminal opening in `/` instead of home directory when no project is open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #46582 to preview
Closes #46574
The
default_working_directory()function incrates/terminal_view/src/terminal_view.rs:1585returnedNonewhen noproject directory was available. The code comment (now removed)
incorrectly claimed "None implies
~on whichever machine we end upon". However, when
Noneis passed toalacritty_terminal, it uses theprocess CWD, not the home directory. On macOS when Zed is launched from
a .
appbundle, the CWD is/.Added a fallback at the end of
default_working_directory()thatexplicitly returns the home directory when no project directory is
found:
directory.or_else(dirs::home_dir)This ensures:
CurrentProjectDirectorywith no project open → home directoryFirstProjectDirectorywith no project open → home directoryAlwaysHome→ home directory (explicitly, not relying on shellbehavior)
{ directory }with invalid directory → home directoryRelease Notes:
/instead of home directory when noproject is open.