# Make \`zed foo/\` add to active window and open sidebar \(\#53254\) · gitcafe/zed

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

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

Visibility: public

Requested revision: d22f8bf2a7624a3084fc0640faec3b30f894ec4c

Requested commit: d22f8bf2a7624a3084fc0640faec3b30f894ec4c

Commit: d22f8bf2a7624a3084fc0640faec3b30f894ec4c

Tree: 7ceb0677c99d3a0ebd6dec46d7a920f90c7bc044

Author: Eric Holk

Committer: GitHub

## Message

```
Make `zed foo/` add to active window and open sidebar (#53254)

Changes the default CLI behavior when opening directories:

- `zed foo/` now adds `foo/` as a new workspace in the active window's
MultiWorkspace and opens the sidebar, instead of creating a new window.
If `bar/` was previously open, both `foo/` and `bar/` are retained as
separate workspaces in the sidebar.
- `zed -n foo/` continues to open a new window without the sidebar
(unchanged behavior).
- `zed -a foo/` continues to add to the existing workspace (unchanged
behavior).

The new behavior is gated on `multi_workspace_enabled` (the `agent-v2`
feature flag). Without the flag, directories open in a new window as
before, avoiding a situation where the workspace gets replaced with no
sidebar to switch back.

The change is contained to `open_paths()` in
`crates/workspace/src/workspace.rs`. When no CLI flag is specified and
no existing workspace matches the paths, we now look for the active
window and set `requesting_window` so that `Workspace::new_local` adds
the new workspace to it rather than creating a new window.

Release Notes:

- N/A
```

## Parents

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

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