zed/crates/gpui/src
Nguyen Anh Tu (Elior) a221a86d49
Fix GPUI crash when using cached view with Input (#50665)
The `draw()` method was calling `.pop()` on `next_frame.input_handlers`
to extract the active input handler for the platform window. This
reduced the Vec length, making cached `paint_range` indices stale. On
the next frame, when a cached view called `reuse_paint()`, it would
index into `rendered_frame.input_handlers` with out-of-bounds indices,
causing a panic: `range start index 1 out of range for slice of length
0`.

**Fix:** Use `.last_mut().and_then(|h| h.take())` instead of `.pop()` to
extract the handler without changing the Vec length. The slot becomes
`None`, which is already handled by `reuse_paint`'s `.take()` logic.

Closes #50456

### Testing

- All 83 existing GPUI unit tests pass
- Manually verified with
[longbridge/gpui-component](https://github.com/longbridge/gpui-component)
`cargo run --example dock`:
  - Switch to Input panel → type text → no crash 
  - Before fix: crash immediately on first keystroke

---

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
*(N/A — no UI changes)*

Release Notes:

- Fixed a crash in GPUI when typing into an Input widget inside a cached
view ([#50456](https://github.com/zed-industries/zed/issues/50456))

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2026-05-14 15:31:46 +00:00
..
app Query for window instead of capturing (#55059) 2026-04-28 08:04:42 +00:00
elements gpui: Fix scrollbar drag position calculation in list (#53378) 2026-05-12 19:17:38 +00:00
keymap keymap_editor: Remove redundant parentheses when displaying keymap context (#50906) 2026-03-17 02:44:12 +00:00
platform Handle hiding cursor on keyboard input at GPUI level (#55664) 2026-05-04 22:51:56 +00:00
text_system gpui_shared_string: Implement SharedString via smol_str (#54649) 2026-04-24 08:58:26 +00:00
window Fix stale pending keybinding indicators on focus change (#44678) 2025-12-17 16:51:16 +00:00
_ownership_and_data_flow.rs gpui: Extract gpui_platform out of gpui (#49277) 2026-02-19 18:57:49 +01:00
action.rs Feat unbind (#52047) 2026-03-21 14:37:34 -04:00
app.rs Handle hiding cursor on keyboard input at GPUI level (#55664) 2026-05-04 22:51:56 +00:00
arena.rs
asset_cache.rs
assets.rs Fix crash and enable GIF animation in markdown preview (#53459) 2026-04-16 10:44:00 +03:00
bounds_tree.rs Performance tweaks (#54321) 2026-04-21 07:25:22 +00:00
color.rs agent_ui: Mermaid diagrams (#56430) 2026-05-13 09:57:17 +00:00
colors.rs
element.rs gpui: Make entities no longer implement Element (they go through AnyElement now) (#48217) 2026-02-03 12:00:22 +01:00
executor.rs gpui: Remove unsound await_on_background helper (#56132) 2026-05-08 09:30:34 +00:00
geometry.rs gpui: Improve Anchored to support center position (#47154) 2026-04-21 09:01:42 +00:00
global.rs
gpui.rs Query for window instead of capturing (#55059) 2026-04-28 08:04:42 +00:00
input.rs gpui: Fix Vim jj keybinding intercepting j key from IME on macOS (#52192) 2026-03-25 01:26:21 +00:00
inspector.rs gpui: Arc GlobalElementId (#40979) 2025-10-23 07:58:33 +00:00
interactive.rs gpui: Implement pinch event support for X11 and Windows (#51354) 2026-03-28 18:41:33 -04:00
key_dispatch.rs Feat unbind (#52047) 2026-03-21 14:37:34 -04:00
keymap.rs Feat unbind (#52047) 2026-03-21 14:37:34 -04:00
path_builder.rs
platform.rs gpui(windows): Fix unwrap panic when monitor goes missing (#55630) 2026-05-06 07:35:40 +00:00
platform_scheduler.rs Remove Executor::close() (#50970) 2026-03-07 04:11:45 +00:00
prelude.rs Merge gpui::Task and scheduler::Task (#53674) 2026-05-05 22:41:13 +00:00
profiler.rs Disable miniprofiler by default (#54645) 2026-04-23 18:41:52 +00:00
queue.rs GPUI on the web (#50228) 2026-02-26 18:36:50 +01:00
scene.rs Performance tweaks (#54321) 2026-04-21 07:25:22 +00:00
shared_uri.rs
style.rs Pixel snapping (#54728) 2026-04-24 08:31:43 +00:00
styled.rs terminal_view: Ensure reported size does not change once content becomes scrollable (#46648) 2026-04-27 22:06:01 +00:00
subscription.rs Fix interleaved subscription operations (#52369) 2026-03-24 22:54:12 -07:00
svg_renderer.rs gpui: Lazy-init font DB in SvgRenderer to avoid per-test overhead (#53381) 2026-04-08 13:06:32 +02:00
tab_stop.rs Bump Rust to 1.91.1 (#42561) 2025-11-12 20:27:04 +00:00
taffy.rs Pixel snapping (#54728) 2026-04-24 08:31:43 +00:00
test.rs agent: LSP tools (#55744) 2026-05-05 09:35:08 +00:00
text_system.rs Implement luminance-based glyph dilation for macOS (#54886) 2026-04-29 07:09:11 +00:00
util.rs Pixel snapping (#54728) 2026-04-24 08:31:43 +00:00
view.rs gpui: Make entities no longer implement Element (they go through AnyElement now) (#48217) 2026-02-03 12:00:22 +01:00
window.rs Fix GPUI crash when using cached view with Input (#50665) 2026-05-14 15:31:46 +00:00