# workspace: Return the created workspace when opening a remote project \(\#62028\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 4aad57fd1f002f9feeea2b7fb6229ccbcd576cb1

Requested commit: 4aad57fd1f002f9feeea2b7fb6229ccbcd576cb1

Commit: 4aad57fd1f002f9feeea2b7fb6229ccbcd576cb1

Tree: 612d953369dc92b9d879381878e41b52a7ed2624

Author: Ben Kunkle

Committer: GitHub

## Message

```
workspace: Return the created workspace when opening a remote project (#62028)

# Objective

Fix the `fallback workspace must not be one of the workspaces being
removed` panic.

Fixes FR-148
Fixes ZED-AKR
Fixes ZED-97M

# Solution

The remote path of `find_or_create_workspace` opened a project, then
returned the
window's *active* workspace instead of the one it created. The open
awaits toolchain
loading and item restoration, and a save prompt from a concurrent
workspace removal
can re-activate a workspace being removed during that wait; the stale
return value
then trips the assert in `MultiWorkspace::remove`.

Return the created workspace from `open_remote_project_inner` and use it
at the
call sites instead of re-reading the active workspace after the await.

# Testing

Added
`test_find_or_create_workspace_returns_the_created_remote_workspace`:
opens a
mock remote project and re-activates the previous workspace mid-open
(standing in
for the save prompt), then asserts the open returns the workspace it
created.
Verified it fails against the pre-fix behavior.

## 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

---

Release Notes:

- Fixed a crash when a workspace was removed while a remote project was
opening in the same window.
```

## Parents

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

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