# Fix panic when immediately closing a window while opening paths \(\#3092\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 559433bed0e01a2d6940ede0a8683d0215002276

Requested commit: 559433bed0e01a2d6940ede0a8683d0215002276

Commit: 559433bed0e01a2d6940ede0a8683d0215002276

Tree: 9d1160a65373eab6ec283bce31d157221915f1a2

Author: Max Brunsfeld

Committer: GitHub

## Message

````
Fix panic when immediately closing a window while opening paths (#3092)

Fixes this panic that I've been seeing in Slack:


[example](https://zed-industries.slack.com/archives/C04S6T1T7TQ/p1696530575535779)


```
thread 'main' panicked at 'assertion failed: opened_items.len() == project_paths_to_open.len()'
crates/workspace/src/workspace.rs:3628
<backtrace::capture::Backtrace>::create
<backtrace::capture::Backtrace>::new
Zed::init_panic_hook::{closure#0}
std::panicking::rust_panic_with_hook
std::panicking::begin_panic_handler::{{closure}}
std::sys_common::backtrace::__rust_end_short_backtrace
_rust_begin_unwind
core::panicking::panic_fmt
core::panicking::panic
<workspace::Workspace>::new_local::{closure#0}::{closure#0}
```

I believe it was caused by a window being closed immediately, while it
was still loading some paths. There was a mismatch in expectation
between the `workspace::open_items` function (which contains this
assertion), and the `Workspace::load_workspace` method. That later
method can return an empty vector if the workspace handle is dropped
while it is executing.

Release Notes:

- Fixed a crash when closing a Zed window immediately after opening it
````

## Parents

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

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

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