terminal: Fix terminal split pane opening in wrong directory #39537
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.
Problem
When splitting a terminal pane, the new pane opens in the root directory (
/) instead of preserving the current working directory of the original terminal.For example, when working in
/Users/modestnerd/Developer/Projects/zed(my pc) and splitting the terminal pane, the new pane would open in/instead of staying in the current directory.Solution
Restructured the fallback logic in
new_pane_with_cloned_active_terminal(terminal_panel.rs:452-456) to ensuredefault_working_directory(workspace, cx)is called as a fallback even when a terminal view exists but itsworking_directory()returnsNone.The fix changes the nested
and_thento useor_elsefor the fallback, ensuring the working directory is always properly resolved before entering the async block.Release Notes: