Skip to content

Conversation

@iamngoni
Copy link
Contributor

@iamngoni iamngoni commented Oct 5, 2025

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 ensure default_working_directory(workspace, cx) is called as a fallback even when a terminal view exists but its working_directory() returns None.

The fix changes the nested and_then to use or_else for the fallback, ensuring the working directory is always properly resolved before entering the async block.

Release Notes:

  • Fixed terminal split pane opening in wrong directory instead of preserving the current working directory
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 5, 2025
@maxdeviant maxdeviant changed the title Terminal: Fixed terminal split pane opening in wrong directory Oct 5, 2025
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril enabled auto-merge (squash) October 5, 2025 06:50
@Veykril Veykril merged commit 68e6d55 into zed-industries:main Oct 5, 2025
24 checks passed
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Oct 11, 2025
…ustries#39537)

## 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
ensure `default_working_directory(workspace, cx)` is called as a
fallback even when a terminal view exists but its `working_directory()`
returns `None`.

The fix changes the nested `and_then` to use `or_else` for the fallback,
ensuring the working directory is always properly resolved before
entering the async block.

Release Notes:

- Fixed terminal split pane opening in wrong directory instead of
preserving the current working directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

2 participants