# gpui: Fix nested deferred support \(\#47770\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 5fb6eadc58a61d888d9f2a93a0aab7d8bf02713e

Requested commit: 5fb6eadc58a61d888d9f2a93a0aab7d8bf02713e

Commit: 5fb6eadc58a61d888d9f2a93a0aab7d8bf02713e

Tree: cf6395b1593899ad1bd0c502a5ae074e54b2c25f

Author: Jason Lee

Committer: GitHub

## Message

````
gpui: Fix nested deferred support (#47770)

Release Notes:

- N/A

To fix crash when use `deferred` in a `deferred`.

```
thread 'main' (4024343) panicked at /Users/jason/.cargo/git/checkouts/zed-a70e2ad075855582/83ca310/crates/gpui/src/window.rs:2411:9:
assertion `left == right` failed: cannot call defer_draw during deferred drawing
  left: 1
 right: 0
```

### When we need use nested deferred?

#### Case 1

- A Popover (used `deferred`) with a form.
- An Input element in the Popover form.
- Input have ContextMenu that used `deferred`.
- User right click Input to open menu.


<img width="539" height="331" alt="image"
src="https://github.com/user-attachments/assets/98c03b1e-58fd-4863-8bcd-0141252d1c51"
/>

#### Case 2

- A Popover (`deferred`) with some content.
- There have a `info` icon in the content to show some tip by open
another Popover.

### Test by `examples/popover.rs`

<img width="916" height="373" alt="image"
src="https://github.com/user-attachments/assets/7ed6a511-6d60-40fb-837b-ebab8f0cba37"
/>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Lukas Wirth <lukas@zed.dev>
````

## Parents

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

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