terminal_view: Fix terminal opening in / when no project is open#46582
Merged
Veykril merged 2 commits intozed-industries:mainfrom Jan 13, 2026
Merged
terminal_view: Fix terminal opening in / when no project is open#46582Veykril merged 2 commits intozed-industries:mainfrom
Veykril merged 2 commits intozed-industries:mainfrom
Conversation
Contributor
Member
|
/cherry-pick preview |
auto-merge was automatically disabled
January 12, 2026 20:01
Head branch was pushed to by a user without write access
github-actions bot
pushed a commit
that referenced
this pull request
Jan 13, 2026
) 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.
zed-zippy bot
added a commit
that referenced
this pull request
Jan 13, 2026
) (cherry-pick to preview) (#46682) Cherry-pick of #46582 to preview ---- 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. Co-authored-by: Max Malkin <60683392+maxmalkin@users.noreply.github.com>
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.
Closes #46574
The
default_working_directory()function incrates/terminal_view/src/terminal_view.rs:1585returnedNonewhen no project directory was available. The code comment (now removed) incorrectly claimed "None implies~on whichever machine we end up on". However, whenNoneis passed toalacritty_terminal, it uses the process 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()that explicitly 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 shell behavior){ directory }with invalid directory → home directoryRelease Notes:
/instead of home directory when no project is open.