# multi_workspace: Allow closing of currently selected project \(\#60602\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 2318f45f4c13d6e57486d25498fe2715d21b14d0

Requested commit: 2318f45f4c13d6e57486d25498fe2715d21b14d0

Commit: 2318f45f4c13d6e57486d25498fe2715d21b14d0

Tree: b19e7a8faaff17878ecb1154e52555d6b037a658

Author: Matei Oprea

Committer: GitHub

## Message

```
multi_workspace: Allow closing of currently selected project (#60602)

# Objective

When working across multiple projects open in the same window, closing
the **currently selected** project requried a two-step flow: switch to
another project first then close the one that you initially wanted to.
The project's close button was hidden on the active project, so the only
way to remove the project was to navigate away first.

## Solution

Always render the close button in the project picker, including for the
active project. Closing the active project now removes it and switches
to a neighboring project automatically.
This worked well for local projects but broke for remote ones. For any
remote neighbor it actually fell through to an empty workspace.

There are 3 cases now: 
1. Activate the neighbor's already open workspace when one exists (now
either if its local or remote)
2. Load the neighbor through the host-aware **find_or_create_workspace**
which connects and opens a remote neighbor when it isn't already open
3. Fallback to an empty workspace only when no neighbor remains

## Testing

- Did you test these changes? If so, how?
- Are there any parts that need more testing?
- How can other people (reviewers) test your changes? Is there anything
specific they need to know?
- If relevant, what platforms did you test these changes on, and are
there any important ones you can't test?

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

> This section is optional. If this PR does not include a visual change
or does not add a new user-facing feature, you can delete this section.

- Help others understand the result of this PR by showcasing your
awesome work!
- If this PR includes a visual change, consider adding a screenshot,
GIF, or video
- A before/after comparison is very useful for changes to existing
features!

While a showcase should aim to be brief and digestible, you can use a
toggleable section to save space on longer showcases:

<details>
  <summary>Click to view showcase</summary>


https://github.com/user-attachments/assets/6e1d1968-702a-4f13-9442-5e90fe7ae9f9

</details>

---

Release Notes:

- Improved the project switcher to allow closing the currently selected
project, switching to a neighboring project (local or remote)
automatically.

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
```

## Parents

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

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