# terminal: Fix terminal split pane opening in wrong directory \(\#39537\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/68e6d555967ced9481e1cf2b216ad5497c8090ac)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 68e6d555967ced9481e1cf2b216ad5497c8090ac

Requested commit: 68e6d555967ced9481e1cf2b216ad5497c8090ac

Commit: 68e6d555967ced9481e1cf2b216ad5497c8090ac

Tree: e7b36aa7db34a764741237dfb9d7f6a8bab179a2

Author: Ngonidzashe Mangudya

Committer: GitHub

## Message

```
terminal: Fix terminal split pane opening in wrong directory (#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
```

## Parents

- [bcd2d269e22540c9a8f710331d82aab7af90d897](https://git.cafe/gitcafe/zed/commit/bcd2d269e22540c9a8f710331d82aab7af90d897?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/68e6d555967ced9481e1cf2b216ad5497c8090ac?format=markdown)
