fbda4f862a2fb03b854636b17bd04be3db3d94de
3559
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
484ae39d7c |
zed: Unify dependencies (#61381)
# Objective Unify dependencies inside of the root `Cargo.toml` to prevent versions from going out of sync and creating copies of dependencies. ## Testing - All tests pass, nothing touches the `Cargo.lock` ## Review Review is easiest by going through commit by commit. Release Notes: - N/A or Added/Fixed/Improved ... |
||
|
|
4feae499a6 |
Reduce overdraw for border-only quads (#61274)
Restore an optimization that I mistakenly removed in https://github.com/zed-industries/zed/pull/54728. Drawing a quad with a border but no fill color will run the quad fragment shader for every transparent interior pixel, which is especially costly when the quad is large. Instead, split these quads into four non-overlapping strips that cover the regions where borders are painted. The side strips own the straight left and right edges, while the top and bottom strips own the horizontal edges and the rounded corners. Previously, this optimization only applied to borders drawn by the Taffy layout. I've decided to reinstate the logic directly in `paint_quad` so that the optimization can be applied more generally... though if this feels like too much policy, we can move it back. This reduces the GPU time spent painting a representative Zed scene by about 20% or so. Release Notes: - N/A |
||
|
|
cd91c84675 |
gpui: Add system notification platform APIs (#61189)
Release Notes: - N/A or Added/Fixed/Improved ... --------- Co-authored-by: John Tur <john-tur@outlook.com> |
||
|
|
9948409b40 |
gpui: Unify raw-window-handle dependency (#61193)
Just something I noticed while skimming through dependencies Release Notes: - N/A or Added/Fixed/Improved ... |
||
|
|
28ed883b99 |
Bump taffy (#61183)
Follow-up to https://github.com/zed-industries/zed/pull/60721 Release Notes: - N/A |
||
|
|
cf028dbd3e |
gpui: Apply EXIF orientation when decoding static images (#61017)
## Context Static images decoded by GPUI ignored their EXIF `Orientation` tag, so JPEGs that rely on it (photos from phones and cameras) rendered rotated or flipped in image preview, Markdown preview, and other `ImageSource` consumers. The `image` crate only exposes orientation through `ImageDecoder::orientation()`, which must be read before the decoder is consumed; `DynamicImage::from_decoder` does not apply it. The old path went straight through `image::load_from_memory_with_format`, so the metadata was never read. Closes #60844. Video of manual test below : [Screencast from 2026-07-15 02-14-41.webm](https://github.com/user-attachments/assets/002b0324-44f8-4ddb-acbd-8c3e070d5248) ## How to Review **Cargo.toml** Raises the workspace `image` dependency minimum from `0.25.1` to `0.25.4`, the first release exposing `orientation()` and `apply_orientation()`. The lockfile already resolves to `0.25.10`, so no lock change is required. **crates/gpui/src/platform.rs** Adds two crate-private helpers. `decode_static_image_from_decoder` reads `orientation()`, decodes to a `DynamicImage`, applies the orientation, then converts RGBA to GPUI's BGRA. `decode_static_image` builds a format decoder from bytes and delegates to it. `Image::to_image_data` now routes its static formats through these helpers instead of `image::load_from_memory_with_format`. Adds `test_image_to_image_data_applies_exif_orientation`, which decodes a 16x32 fixture stored upside down with EXIF Orientation 3 and asserts the corner pixels were flipped upright; the test fails if orientation is dropped. **crates/gpui/src/elements/img.rs** Routes `ImageAssetLoader` (Markdown paths, URLs, embedded resources) through the same helpers, including the static WebP branch. GIF and animated-WebP frame handling are left unchanged, since animated orientation is out of scope. ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the UI/UX checklist - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed static images ignoring their EXIF orientation, which caused some JPEGs to render rotated or flipped in image and Markdown preview. |
||
|
|
b8a184ba26 |
gpui: Fix clicks on window prompts dismissing popovers behind them (#61136)
I noticed that when Zed renders prompts in-window (Linux, or `use_system_prompts: false`), clicking a prompt button also dismisses the popover behind it. Native macOS dialogs don't have this problem since the click goes to the OS dialog and the window never sees it. For example, in the worktree picker: 1. Delete a dirty worktree. 2. Confirm "Force Delete". 3. Mouse down dismissed the picker, which aborted the confirmed deletion. This PR makes GPUI-rendered prompts behave the same way as native. If someone actually wants to observe mouse downs during a prompt, the raw `window.on_mouse_event` API still sees every event. macOS: https://github.com/user-attachments/assets/9f85622f-c0d1-44f2-83f9-8378d9d7d13b Before GPUI prompt: https://github.com/user-attachments/assets/d1845ba1-9886-4733-8cf6-ab32424416e1 After GPUI prompt: https://github.com/user-attachments/assets/27936aca-8de5-4da8-88be-d88dbc1259d8 Release Notes: - Fixed confirmation dialog buttons dismissing the popover underneath them on click when using Zed-rendered prompts. |
||
|
|
b6a1c2706e |
gpui: Avoid redundant group hover redraws (#61118)
Anonymous elements with group hover styles have no persistent hover state. The prepaint mouse handler treated missing state as unhovered and notified the current view for every pointer movement within the group. This made controls such as switches redraw continuously while the pointer moved over them. Let anonymous elements use the existing paint-time hover transition handler. Only elements with persistent hover state now update that state and notify from prepaint. Add regression coverage for entering, moving within, and leaving an anonymous hover group. Signed-off-by: Daan De Meyer <daan@amutable.com> Release Notes: - N/A Signed-off-by: Daan De Meyer <daan@amutable.com> |
||
|
|
e6efd6fddc |
Fix post-taffy-bump layouting issues (#61107)
Follow-up to https://github.com/zed-industries/zed/pull/60721 Before: <img width="564" height="470" alt="before" src="https://github.com/user-attachments/assets/d825464d-f8d9-4fa1-bee3-42b5f615d4ba" /> <img width="745" height="221" alt="image" src="https://github.com/user-attachments/assets/18139bec-6778-491a-9aa5-0112bd121723" /> After: <img width="576" height="472" alt="after" src="https://github.com/user-attachments/assets/4c3c37cf-12c4-421e-98e9-cc6e40aa099d" /> <img width="812" height="275" alt="image" src="https://github.com/user-attachments/assets/407e06b4-101f-4984-8d5b-4e33895b5ae9" /> ### Bug 1 — constraint-blind text layout cache (the collapse) `TextLayout`'s measure closure is stateful (each call overwrites the shared element state used for painting), and its cache check served cached sizes to unconstrained probes regardless of the constraints they were computed under: 1. `uniform_list::measure_item` lays an item out at `(MinContent, MinContent)`; the row's `min_w_0` lets it shrink to ~0, so labels get truncated at a tiny width — and that tiny size lands in the element state. 2. The real layout probes the label's flex base size with `available_space.width = MaxContent` (taffy maps Definite → MaxContent). Truncated labels are `whitespace_nowrap`, so both `wrap_width` and `truncate_width` were `None` → the cache check passed → the poisoned tiny size became the flex basis → labels rendered at ~5 chars. **Fix**: record `truncate_width` in `TextLayoutInner` and never serve a cached layout that was computed *with* truncation to an unconstrained probe; the honest intrinsic size is recomputed instead, and the final `PerformLayout` call re-truncates against the real resolved width. ### Bug 2 — truncation width math disagrees with shaping (the ~2-char loss) After fix 1, rows got their full width, but exact-fit strings like `Cargo.toml` still lost ~2 chars: - Sizing measures via `shape_text` (real shaping with kerning); the element gets exactly `ceil(shaped_width)`. - The truncation decision (`LineWrapper::should_truncate_line_middle` etc.) sums **per-character advances** — no kerning — with zero tolerance, overestimating width for some glyph sequences. Text sitting in a box of exactly its own measured width got truncated, losing ~2 chars to fit the `…`. String-dependent (kerning pairs), hence `Cargo.toml` broke while `Cargo.lock` didn't. - Previously masked because taffy 0.10 usually skipped the final measure invocation, so the truncation path rarely ran with an exact-fit width. **Fix**: before truncating (nowrap case, `wrap_width.is_none()`), shape the untruncated text and skip truncation if the *shaped* width fits — matching CSS `text-overflow`, which only activates on actual overflow. Cheap: the shaping result is a `line_layout_cache` hit from the earlier untruncated sizing probe. ### Bug 3 — `MinContent` used instead of `MaxContent` that caused over truncation of certain labels Release Notes: - N/A |
||
|
|
22c0cbd009 |
gpui: Bump taffy from 0.10.1 to 0.12.1 (#60721)
Migrates the alignment conversions to taffy's new safe-alignment style types: `AlignItems`/`AlignContent` and friends are now structs pairing a keyword with a safety modifier, constructed via associated constants (e.g. `AlignItems::START`) instead of enum variants. The motivating change in this release is [taffy #911](https://github.com/DioxusLabs/taffy/commit/df2663aad35801f7522f6878a0300646dfe624f7) ("More correct caching logic"), which keys taffy's per-node measure cache on axis, parent size, and available space. Today GPUI is largely immune to the old cache-key conflation because text answers every sizing probe with the same width; the follow-up PR in this stack (honest min-content text measurement) returns different sizes for different constraints, which makes cache-key correctness a prerequisite. 0.12.1 additionally hotfixes two block layout/caching regressions in 0.12.0, and 0.11.0's grid fix (resolving item percentages against the grid area rather than the container) comes along as well. Stack: 1. **This PR** — taffy 0.12.1 2. #60722 — honest min-content text measurement 3. #60723 — CSS `auto` grid tracks for table-like column sizing Release Notes: - N/A |
||
|
|
e963df8029 |
gpui: Linux wayland set exclusive zone and edge (#60163)
# Objective The exclusive zone and exclusive edge of a wlr-layer-shell surface could only be set once, at creation, through `LayerShellOptions`. This adds runtime setters so a live layer-shell window such as a panel can update them without being recreated. ## Solution Add two methods on `Window`: - `set_exclusive_zone` updates how much screen space the surface reserves. A positive value reserves that distance from the anchored edge, 0 lets the surface be moved out of others' exclusive zones, and -1 ignores reserved space and may extend under other surfaces. - `set_exclusive_edge` chooses which anchored edge the exclusive zone applies to, which is needed to disambiguate a corner-anchored surface. Setting an exclusive edge the surface is not anchored to is a fatal protocol error, so the edge is validated (it must be a single edge that the surface anchor contains) and an invalid edge is logged and ignored. The same validation now also guards the creation path. Both setters only commit the surface when a change actually applies, and are no-ops on non-layer-shell windows and on other platforms. This is where these 2 are documented: https://wayland.app/protocols/wlr-layer-shell-unstable-v1#zwlr_layer_surface_v1:request:set_exclusive_zone https://wayland.app/protocols/wlr-layer-shell-unstable-v1#zwlr_layer_surface_v1:request:set_exclusive_edge ## Testing - Verified with a small local layer-shell window (a top bar anchored TOP, LEFT, RIGHT) with buttons that call the setters at runtime - No automated test was added, since this calls through to the compositor. - Reviewers without a layer-shell capable compositor (for example GNOME/Mutter) cannot exercise this, as `zwlr_layer_shell_v1` is unavailable there, I tested this on the [Smithay](https://github.com/Smithay/smithay/) based compositor [niri](https://github.com/niri-wm/niri) ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - N/A |
||
|
|
5cc3fbcb12 |
Fix project panel follow focus issues (#60974)
Closes https://github.com/zed-industries/zed/issues/60939 Closes https://github.com/zed-industries/zed/issues/60940 Release Notes: - Fixed focus follows mouse in project panel's blank space |
||
|
|
2adb49ea16 |
Disable all spinners in Zed (#60614)
Closes https://github.com/zed-industries/zed/pull/48577 Part of https://github.com/zed-industries/zed/issues/8043 See https://zed-industries.slack.com/archives/C07NUKHLVUZ/p1783335475957139 for context. Release Notes: - Allow to reduce animations with `"reduce_motion": "on"` settings |
||
|
|
58f2b47005 |
gpui: Fix crash when opening a popover from inside another popover (#60926)
Opening a popover from inside another popover (e.g. the branch picker's new filter menu, when the picker is hosted in the git panel or title bar) corrupted the frame-caching bookkeeping for whichever cached view contained them. The corruption was invisible until a later, unrelated redraw reused that view's cached subtree, at which point the window crashed (debug) or could misroute input events (release). Fixed by processing deferred draws in place so their recorded positions remain valid across frames; added a regression test reproducing the crash via a cached panel hosting nested popovers. Release Notes: - Fixed the branch picker menu in the Git Panel, which was previously broken due to popovers-within-popovers not being possible in GPUI. |
||
|
|
1a06fd4f2b |
Add a bunch of stray design refinement throughout (#60937)
This PR is a collection of grab bag UI design refinements across the entire app. Most of them are minor icon fixes/standardizations, spacing, and sizing tweaks. The one change that ended up getting a bit bigger than I initially anticipated is the debugger panel tabs improvements; added a bunch of tweaks there to make it look slicker. A relevant change is a small one-line change to the GPUI div element where it wouldn't add drag-over styles to elements that aren't initially a hitbox target. Given I wanted to pull off the drop indicator you see on the video below, this turned out to be needed: https://github.com/user-attachments/assets/964b456a-eef0-42bb-a433-7dac54ab8ec8 --- Release Notes: - N/A |
||
|
|
ab43548338 |
a11y: Landmarks and menu improvements (#60397)
Fixes menu a11y, and adds landmarks with `F6`-navigation. Also fixes a GPUI bug, and adds debug actions for dumping a11y tree info. Since `F6` was already in use by the pause debugger keybind, also tightens up the debugger keybind context so they require an active debugger session. When there is one active, `F6` stays as pause debugger. `ctrl-F6` always works to go to the next landmark. Also adds an "accessible mode" setting. Currently, this only controls whether we show all menus all the time, but I suspect it will expand significantly in the future. Also adds `.aria_keyshortcuts()` API, but it's not wired up within accesskit adapters, so is not yet reported to screen readers. --- Release Notes: - N/A or Added/Fixed/Improved ... |
||
|
|
a932df5550 |
gpui: Implement window attention (#58779)
Release Notes: - On agent notifications, the corresponding zed window will now mark itself for OS level attention --------- Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com> |
||
|
|
dc6d010a75 |
editor: Add support for pasting images in Markdown (#58588)
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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #18112 Release Notes: - Added support for pasting images from clipboard into Markdown files --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> |
||
|
|
9ba1a0116a |
macos: Fix window move controls are disabled (#60620)
Closes https://github.com/zed-industries/zed/issues/60595 cc Anthony-Eid since you did an initial pass on this. # Objective Currenly on macOs there is no way right now after the following regression to use window management short keys to move them around. This worked before, but was regressed initially in https://github.com/zed-industries/zed/pull/59836 that tried fixing a macos 27 clicking delay issue on the titlebar. That accidentally set the `native_window.setMovable_(is_movable as BOOL)` to false. Because of this mocos detects this and disables the window managements actions because it thinks the window can/should not be able to move. ## Solution The macOS 27 click delay actually comes from AppKit's native titlebar dragging, not from `NSWindow.isMovable`. The problem is that `is_movable` is also what enables the Window menu's tiling options, and #59836 used it to turn off dragging, which disabled the tiling menu as a side effect. To fix this, I restored `is_movable` to its real meaning so the tiling menu works again, and added a separate `WindowOptions::app_owns_titlebar_drag` flag for windows that draw their own titlebar and handle dragging via `Window::start_window_move`. On macOS this tells AppKit to stop owning titlebar drags (removing the click delay) without affecting `is_movable`. Zed's main window now sets both `is_movable: true` and `app_owns_titlebar_drag: true`, so the tiling menu stays enabled, the click delay is gone. I also added a `window_movable` gpui example to make this behavior easy to test manually. ## Testing I added a gpui test example that helps testing this bug. You can run the newly added gpui example with 4 different window configurations that should confirm that this change is the right one for all of the window types that we have. ## 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 **After** (note this now shows the window managements entries as they were greyed out.) https://github.com/user-attachments/assets/192cc0e1-15d8-486f-b788-a92bb51fb7d1 **GPUI** (test examples with different window configurations.) https://github.com/user-attachments/assets/c9e0f4d3-606b-4cd7-b4d8-a5bb16508164 --- Release Notes: - Fix macos window management controlls were grayed out/not working |
||
|
|
cd66954965 |
gpui: Add container_query element (#60774)
Adds a `container_query` element to GPUI, in the spirit of CSS container
queries: the element's own size is determined solely by its style and
the space offered by its parent, and once that size is known the
provided closure is called with the measured size to build the contents.
```rust
container_query(|size, _window, _cx| {
if size.width < px(240.) {
div().child("Narrow layout")
} else {
div().child("Wide layout")
}
});
```
Implementation notes:
- Defaults to filling its parent (`size_full()` semantics), overridable
via `Styled` since contents can't influence the container's size (the
same constraint CSS container queries impose).
- Reworks the `grid_layout` example (the Holy Grail layout) to
demonstrate it: the three-column grid collapses to a stacked column when
the window is narrower than 400px, and the header shows the live
measured width.
Release Notes:
- N/A
---------
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
|
||
|
|
c480145ca8 |
gpui: Fill auto-sized window roots to the viewport (#60739)
Window roots whose size is `auto` now stretch to fill the window, the way the root element on the web fills the initial containing block. Previously a window root with no explicit size shrink-wrapped its content (flex/grid roots collapsed to content size in both axes), which is why every root view needed `size_full()`. Mechanically: `draw_roots` requests layout for the window root (and prompt roots), then `TaffyLayoutEngine::stretch_auto_size_to_fill` rewrites any `auto` dimension on the root node to the viewport size before layout runs. Explicitly styled root dimensions are preserved, and tooltips, drags, and anchored/deferred draws keep their shrink-wrap semantics. Includes regression tests covering both the auto-fill and explicit-size cases (the auto case collapses to 0×0 without the fix). Release Notes: - N/A --------- Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com> |
||
|
|
870feae369 |
gpui: Add mobile/touch API surface (#60496)
TODO: - [ ] Remove slop comments - [ ] Review APIs in detail # Objective - This PR aims to add official mobile API surfaces to GPUI ## Solution - This PR cross references several internal experiments to come up with a general cross-platform abstraction for core input mechanisms, but defers actual implementations to later. These are intended to be a common base to build off of. ## Testing - Yes, as mentioned above with external experiments ## Self-Review Checklist: - [ ] 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: - N/A |
||
|
|
711e286c7f |
gpui: Store GPU-facing bools as PaddedBool32 to avoid uninitialized padding (#60482)
`PolychromeSprite` in `crates/gpui/src/scene.rs` is `#[repr(C)]` and had a `grayscale: bool` field followed by 3 compiler-inserted padding bytes that were never written. The wgpu renderer's `instance_bytes` reinterprets `&[PolychromeSprite]` as `&[u8]` via `slice::from_raw_parts` and passes it to `queue.write_buffer`, so those uninitialized padding bytes were exposed behind a shared `&[u8]` on every frame that draws an image or emoji, which is undefined behavior. Rather than widening the field to a raw `u32` (which would suggest values other than 0 and 1 are meaningful), this introduces `PaddedBool32`: a `#[repr(transparent)]` wrapper around `u32` whose only public constructor is `From<bool>`, so the 0-or-1 invariant is enforced by the type while the layout has no padding. `Underline.wavy`, which was already a raw `u32` for the same reason, is converted too. cbindgen emits the wrapper as `typedef uint32_t PaddedBool32;`, so the generated Metal header and shaders are unchanged. The WGSL and HLSL shaders already declared these fields as `u32`/`uint`; their `& 0xFFu` masks, which existed to ignore the garbage padding bytes, are now simplified to plain comparisons. Release Notes: - N/A |
||
|
|
01d5096a3f |
gpui: Fix hover state not clearing when mouse leaves window (#60275)
# Objective Fix two gaps in element hover tracking at window boundaries. Hover was only re-evaluated on `MouseMove`, so when the pointer left the window no event fired `on_hover(false)` and the element stayed hovered. Symmetrically on Wayland, no `Motion` follows `Enter` until the pointer moves again, so hover was not established at the entry pixel. Both cases are easy to miss since most hover-styled elements don't sit flush against the window edge, but they surfaced while implementing layer_shell popups with input_regions, which should close when stop hovering. ## Solution The hover compare-and-fire logic in `div` is refactored into a shared `update_hover` closure, and a second listener on `MouseExitEvent` clears hover when the pointer leaves the window. It clears unconditionally because `MouseExited` doesn't update the tracked mouse position, so a hit test during that dispatch would still report the element as hovered. On Wayland, a `MouseMove` is synthesized at the entry position on `wl_pointer.enter`, mirroring the `MouseExited` already dispatched on `Leave`. ## Testing Tested manually on Wayland/Linux: hover on a window-edge element clears when the pointer leaves the window, and hover is established immediately when the pointer enters a surface with an element under the entry pixel. Not tested on other platforms. The `div` change relies on each platform's existing `MouseExited` dispatch: macOS and X11 emit it, so they get the exit fix too. Windows never dispatches `MouseExited` (`WM_MOUSELEAVE` only flips the window-level hover flag), so the stuck-hover case might remain there, unchanged from before. Before: https://github.com/user-attachments/assets/6af83bb3-de9d-40e2-a64c-bdefc98fc96d After: https://github.com/user-attachments/assets/721a9b5c-108a-499f-867e-da111836a34a Here is an example application to test this: ```rs #![cfg_attr(target_family = "wasm", no_main)] use gpui::{ App, Bounds, Context, Window, WindowBounds, WindowOptions, div, prelude::*, px, rgb, size, }; use gpui_platform::application; struct HoverExit { hovered: bool, } impl Render for HoverExit { fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { // Fills the whole window so its edge is the window edge: moving the mouse // out of the window is what exercises the MouseExited path. div() .id("hover-exit") .size_full() .flex() .justify_center() .items_center() .text_xl() .text_color(rgb(0xffffff)) .bg(if self.hovered { rgb(0x585f58) } else { rgb(0x505050) }) .child(if self.hovered { "HOVERED" } else { "not hovered" }) .on_hover(cx.listener(|this, hovered, _, cx| { this.hovered = *hovered; cx.notify(); })) } } fn run_example() { application().run(|cx: &mut App| { let bounds = Bounds::centered(None, size(px(240.), px(160.0)), cx); cx.open_window( WindowOptions { window_bounds: Some(WindowBounds::Windowed(bounds)), app_id: Some("gpui-hover-exit".to_string()), ..Default::default() }, |_, cx| cx.new(|_| HoverExit { hovered: false }), ) .unwrap(); cx.activate(true); }); } #[cfg(not(target_family = "wasm"))] fn main() { run_example(); } #[cfg(target_family = "wasm")] #[wasm_bindgen::prelude::wasm_bindgen(start)] pub fn start() { gpui_platform::web_init(); run_example(); } ``` ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed element hover state not clearing when the mouse leaves the window |
||
|
|
636e764737 |
gpui: Add parent-anchored native popup windows (with wayland xdg_popup implementation only so far) (#60232)
# Objective gpui can't show UI that extends past the window it belongs to. Menus, dropdowns and tooltips are drawn as elements inside the window, so they clip at its edges. This PR adds a window kind for platform-native popups anchored to a parent window, as groundwork for real native menus, dropdowns and tooltips. ## Solution `WindowKind::AnchoredPopup(PopupOptions)` opens a popup positioned relative to a parent window. Instead of giving the popup an absolute position, you describe where it should go and the platform figures out the rest: - `parent`: the window to anchor to - `anchor_rect`: a rectangle in the parent, e.g. the button that opened the menu - `anchor` and `gravity`: which point of that rect to attach to, and which direction to grow - `constraint_adjustment`: what the platform may do if the popup would leave the screen (slide, flip, resize) - `grab`: menu behavior, the popup takes focus and is dismissed when clicking outside the app The popup's size comes from `WindowOptions::window_bounds`. This model mirrors Wayland's `xdg_positioner`, where the compositor owns positioning and the client can only describe intent. Since that's the most restrictive case, the other platforms can implement the same description later with simple math against screen bounds. Only Wayland is implemented so far, via `xdg_popup` on top of the existing surface implementation. Popups can be parented to toplevels, layer-shell surfaces (a menu opened from a panel) and other popups (nested menus). macOS, Windows, X11 and web reject the kind with `PopupNotSupportedError`, so callers can detect that and fall back to in-window popovers. Some Wayland details that might help during review: - Anchor rects are translated from gpui coordinates into the parent's window geometry space and clamped to it. A rect outside the geometry, or with zero size, is a fatal protocol error - Resizing a mapped popup goes through `xdg_popup.reposition` - Mouse press serials are now recorded on press only, not release. Compositors decline grabs and interactive moves that reference a release serial ## Testing Tested manually on Wayland with an example app: the menu opens anchored below its button, extends past the parent window, flips above the button near the bottom of the screen, and a grabbing popup is dismissed when clicking into another application. Nested menus were tested in one of my projects (ignore that they are ugly, that's just a prototype 😛): https://github.com/user-attachments/assets/2cd3e2e9-87f7-4b02-986f-48e5633e205c I also have a complete runnable example demonstrating it. I did not add it to the PR, because this might give the impression that `WindowKind::AnchoredPopup` are a complete implementation, despite only working on wayland so far: <details> <summary>Click to view example</summary> ```rust //! Example and manual test for platform-native popups (`WindowKind::AnchoredPopup`). //! //! A native popup is a real, parent-anchored window that can extend beyond its parent onto the //! screen, unlike gpui's in-window popovers. Run it, open the menu, and confirm the points listed //! in the window. On a platform without an implementation the button reports that popups are not //! supported instead of opening anything. //! //! Run with: cargo run -p gpui --example popup #![cfg_attr(target_family = "wasm", no_main)] use gpui::{ AnyWindowHandle, App, Bounds, Context, MouseButton, SharedString, Window, WindowBounds, WindowHandle, WindowKind, WindowOptions, div, point, popup::*, prelude::*, px, rgb, size, }; use gpui_platform::application; /// The trigger button, at a fixed position so the popup can anchor to a known rectangle. Real code /// would anchor to the measured bounds of whatever element opens the popup. const BUTTON_BOUNDS: Bounds<gpui::Pixels> = Bounds { origin: point(px(24.), px(24.)), size: size(px(200.), px(32.)), }; const POPUP_SIZE: gpui::Size<gpui::Pixels> = size(px(260.), px(320.)); struct Menu; impl Render for Menu { fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement { let item = |label: &str| { div() .id(label.to_string()) .px_3() .py_1() .rounded_sm() .hover(|this| this.bg(rgb(0x3a3a3a))) .cursor_pointer() .child(label.to_string()) .on_click(|_, window, _| window.remove_window()) }; div() .id("menu-root") .size_full() .p_1() .flex() .flex_col() .gap_0p5() .bg(rgb(0x2a2a2a)) .text_color(gpui::white()) .rounded_md() .border_1() .border_color(rgb(0x454545)) .child(item("Foo")) .child(item("Bar")) .child(item("Baz")) .child(item("Qux")) .child(item("Alice")) .child(item("Bob")) } } struct PopupExample { menu: Option<WindowHandle<Menu>>, status: SharedString, } impl Default for PopupExample { fn default() -> Self { Self { menu: None, status: "Click \"Open menu\" to open a native popup.".into(), } } } impl PopupExample { /// Closes the menu if it is open. Returns true if a menu was actually open. fn close_menu(&mut self, cx: &mut App) -> bool { match self.menu.take() { Some(menu) => menu .update(cx, |_, window, _| window.remove_window()) .is_ok(), None => false, } } fn toggle_menu(&mut self, parent: AnyWindowHandle, cx: &mut App) { if self.close_menu(cx) { return; } match open_menu(parent, cx) { Ok(menu) => { self.menu = Some(menu); self.status = "Menu open. Dismiss it by selecting an item, clicking elsewhere in \ this window, or clicking another application." .into(); } // A real application would fall back to an in-window popover here. Err(error) => { self.status = format!("Failed to open a native popup: {error}").into(); log::error!("failed to open popup: {error}"); } } } } impl Render for PopupExample { fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { let bullet = |text: &str| div().child(format!("• {text}")); div() .id("root") .size_full() .bg(rgb(0xf7f7f7)) .text_color(rgb(0x222222)) // Same-app clicks don't auto-dismiss a grabbing popup (see `PopupOptions::grab`). .on_mouse_down( MouseButton::Left, cx.listener(|this, _, _window, cx| { this.close_menu(cx); }), ) .child( div() .size_full() .p_5() .pt(px(76.)) .flex() .flex_col() .gap_3() .child(div().text_xl().child("Native popup test")) .child(div().text_sm().child( "WindowKind::AnchoredPopup opens a real, parent-anchored window that can \ extend past this window onto the screen. Only some platforms implement \ it so far.", )) .child( div() .flex() .flex_col() .gap_1() .text_sm() .text_color(rgb(0x555555)) .child(div().child("Verify:")) .child(bullet("The menu opens anchored below the button.")) .child(bullet( "The menu extends past the bottom edge of this window.", )) .child(bullet( "Near the bottom of the screen, the menu flips above the button.", )) .child(bullet("Clicking another application dismisses the menu.")) .child(bullet( "Selecting an item or clicking in this window dismisses it.", )), ) .child( div() .text_sm() .text_color(rgb(0x333333)) .child(self.status.clone()), ), ) .child( div() .absolute() .left(BUTTON_BOUNDS.origin.x) .top(BUTTON_BOUNDS.origin.y) .w(BUTTON_BOUNDS.size.width) .h(BUTTON_BOUNDS.size.height) .flex() .items_center() .justify_center() .bg(rgb(0xffffff)) .border_1() .border_color(rgb(0xd0d0d0)) .rounded_md() .cursor_pointer() .id("open-menu") .active(|this| this.bg(rgb(0xeeeeee))) .child("Open menu ▾") // Open on mouse-down, not on click, so the grab is taken while the button is still held. .on_mouse_down( MouseButton::Left, cx.listener(|this, _, window, cx| { // Don't let the window handler above close the menu we are opening. cx.stop_propagation(); this.toggle_menu(window.window_handle(), cx); }), ), ) } } fn open_menu(parent: AnyWindowHandle, cx: &mut App) -> anyhow::Result<WindowHandle<Menu>> { cx.open_window( WindowOptions { titlebar: None, // Sizes the popup. The platform decides the position, so the origin is ignored. window_bounds: Some(WindowBounds::Windowed(Bounds { origin: point(px(0.), px(0.)), size: POPUP_SIZE, })), kind: WindowKind::AnchoredPopup(PopupOptions { parent, anchor_rect: BUTTON_BOUNDS, // Anchor to the button's bottom-left and grow down-right so the menu drops beneath it. anchor: PopupAnchor::BottomLeft, gravity: PopupGravity::BottomRight, // Slide horizontally and flip vertically if the menu would leave the screen. constraint_adjustment: PopupConstraintAdjustment::SLIDE_X | PopupConstraintAdjustment::FLIP_Y, offset: point(px(0.), px(4.)), // Grab input so the compositor dismisses the popup on clicks into other applications. grab: true, }), ..Default::default() }, |_, cx| cx.new(|_| Menu), ) } fn run_example() { application().run(|cx: &mut App| { cx.open_window( WindowOptions { window_bounds: Some(WindowBounds::Windowed(Bounds { origin: point(px(100.), px(100.)), size: size(px(420.), px(300.)), })), ..Default::default() }, |_, cx| cx.new(|_| PopupExample::default()), ) .unwrap(); cx.activate(true); }); } #[cfg(not(target_family = "wasm"))] fn main() { run_example(); } #[cfg(target_family = "wasm")] #[wasm_bindgen::prelude::wasm_bindgen(start)] pub fn start() { gpui_platform::web_init(); run_example(); } ``` </details> ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - N/A |
||
|
|
3f135978df |
csv_preview: Add row filtering feature (#60339)
# Objective CSV feature needs row filtering feature by column values. This PR provides base implementation of it with barebones ui. > NOTE: Sleek UI with search & proper scrolling hanling is implemented in next PR. It's stacked on top to reduce review scope ## Solution - New `FilterEntry` / `FilterEntryState` model in `table_data_engine/filtering_by_column.rs` tracking per-column applied/candidate filter values - Filtering runs in the background (`feat: Implement background filtering`) so large CSVs don't block the UI thread while a filter is applied - Filter menu entries reflect live counts and support a configurable sort order (`FilterSortOrder`, added in `renderer/settings.rs` / `settings.rs`) - Filter/sort trigger buttons on column headers are hidden until hover, using `GradientFade` (new in `ui/src/components/gradient_fade.rs`) to fade content behind them ## Testing Filter chain tested on csv fixtures with multiple filters applied sequentially columns. ## Self-Review Checklist: (todo) - [ ] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [ ] 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) (out of scope of this pr) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase <img width="664" height="249" alt="image" src="https://github.com/user-attachments/assets/0e9b0a91-1a27-4e0f-a8d4-fdce36735131" /> <img width="663" height="205" alt="image" src="https://github.com/user-attachments/assets/0428f5c6-6aaa-4891-b010-ca79803f6613" /> --- Release Notes: - Added initial row filtering UI & logic |
||
|
|
cf4a373230 |
Unify Render and RenderOnce into View (#58087)
This allows us to build powerful and flexible Input and TextArea components 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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
244a8d349c |
gpui: Add run_embedded and ApplicationHandle for externally driven run loops (#60574)
On ordinary platforms, `Platform::run` blocks for the lifetime of the app, and `Application::run`'s stack frame keeps the app state alive. Embedded platforms invert that: the run loop belongs to someone else. `Application::run_embedded` supports that shape: it starts the app exactly like `run()`, but returns an `ApplicationHandle` holding the strong app handle. Release Notes: - N/A |
||
|
|
4293014f8a |
Limit SVG Pixmap size to avoid GPUI texture allocation errors (#56468)
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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) (Arguably no, but it's an okay compromise methinks) - [ ] Tests cover the new/changed behavior (I'm unsure how one would properly test this, sorry!) - [x] Performance impact has been considered and is acceptable Closes #56466 To be completely honest I don't know if this is a good fix or not, it does fix the problem I was running into where opening the large mermaid diagram would blow up VRAM. It doesn't look amazing visually but I would consider this behavior better, if it's not a good fix then that's okay:) I chose 8192 because 8192 only brings VRAM usage up ~100MB in my testing while 16384 brought my VRAM usage up to about 1GB from 150-200MB, for lower end systems this seems unacceptable. Before: I can't take a screenshot of the before at this point because it eats my system VRAM & Memory too fast. As a text description; It would show a large empty rectangle where the mermaid diagram should be and blow up Zed's VRAM usage from ~300MB to ~22GB (all of the available VRAM in my system) After: <img width="1698" height="763" alt="image" src="https://github.com/user-attachments/assets/62eb7c95-cca8-43f9-8257-c7e529f26e8d" /> <img width="1000" height="31" alt="image" src="https://github.com/user-attachments/assets/4315c029-3cdd-44f6-ac78-971d125ab700" /> (Up from ~150MB), the 257MiB figure is the GPU Memory. Release Notes: - N/A? Co-authored-by: Lukas Wirth <lukas@zed.dev> |
||
|
|
3699843254 |
gpui: Refresh mouse position after bounds changes (#60421)
## Summary - Refresh GPUI's cached mouse position when window bounds change so hover hit-testing uses the current cursor position after live resize. - Return X11 mouse positions in window-relative logical pixels to keep `PlatformWindow::mouse_position()` consistent with other backends. Fixes #57354 ## Testing - `cargo fmt -p gpui -p gpui_linux` - `cargo check -p gpui_linux` - `cargo check -p gpui` ## Suggested .rules additions - In GPUI platform backends, `PlatformWindow::mouse_position()` should return window-relative logical pixels; use separate APIs or fields for global/device-pixel coordinates. Release Notes: - Fixed incorrect hover state while resizing GPUI windows. |
||
|
|
a232891710 |
gpui: Fix clear drag overlay when external drag ends outside window (#45759)
Release Notes: - Fixed clear drag overlay when external drag ends outside window When dragging files from macOS Finder over the project panel and then dragging back to Finder, the drag overlay remained visible because the drag state was not properly cleaned up. The root cause was that only `draggingExited:` was handled, but not `draggingEnded:`. On macOS: - `draggingExited:` is called when the drag leaves the window area - `draggingEnded:` is called when the drag operation ends entirely When a user drags a file back to Finder and drops it there, `draggingEnded:` is called but was not being handled. --------- Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com> |
||
|
|
ae4b9122dc |
gpui: Add ParentElement impl for AnimationElement (#54145)
Hello, I've been loving using GPUI! Recently I noticed that calling `.with_animiation()` would give an `AnimationElement<E>` which did not allow `.child()` to be called on it. It was a quick fix, I hope it's a quick easy merge but let me know if you'd like anything changed :) 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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A Co-authored-by: Lukas Wirth <lukas@zed.dev> |
||
|
|
b992659378 |
gpui: Add input region support for Wayland windows (#60161)
# Objective Wayland windows have no way to restrict which parts of the surface accept pointer and touch input. This adds support for setting an input region, so events outside it pass through to whatever is below the window. This is useful for shaped or partially click-through windows. Clicks in green area can pass through the window, clicks in red area do not: <img width="1057" height="395" alt="image" src="https://github.com/user-attachments/assets/2039af62-e43b-4834-b877-edad2a8f5ccf" /> ## Solution Add `Window::set_input_region`, which takes `Option<&[Bounds<Pixels>]>`: - `Some(rects)` restricts pointer and touch input to the union of the rectangles, in window coordinates. - `Some(&[])` is an empty region, so the window receives no input at all and is fully click-through. - `None` resets the region to the default, so the whole window receives input again. On Wayland this maps to `wl_surface.set_input_region`, building a `wl_region` from the rectangles or clearing it for `None`, and commits so the change applies immediately rather than waiting for the next frame. The method is a no-op on other platforms. ## Testing Tested on Linux with Wayland. - Tested in my own GPUI application, which uses a fullscreen layer for overlays while allowing clicks outside of the rendered elements to be passed through to the underlying windows. - No automated test was added, since this calls through to the compositor and is checked by observing input routing. ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - N/A |
||
|
|
d5c3183188 |
Revert "Fix hanging updates after system sleep (#60301)" (#60321)
This reverts commit
|
||
|
|
bf39dab4e1 |
Fix hanging updates after system sleep (#60301)
When Zed was downloading an update and the machine went to sleep, the download would hang indefinitely on wake because the in-flight TCP connection had silently died and nothing ever timed it out or retried. This adds an inactivity `read_timeout` to the HTTP client so a stalled response body errors out instead of hanging forever (slow-but-progressing downloads are unaffected, since the timeout resets on each chunk). It also promotes `App::on_system_wake` to a multi-subscriber `Subscription` API and uses it in the auto-updater to cancel an interrupted check/download on wake and start a fresh attempt. ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fix hanging Zed update downloads after system sleep |
||
|
|
a1a3122b2f |
gpui_windows: Add missing windows dependency feature (#59886)
https://github.com/zed-industries/zed/pull/59831 broke the crate from compiling standalone --- Release Notes: - N/A or Added/Fixed/Improved ... |
||
|
|
fea22b3934 |
gpui: Fix xdg_toplevel app_id set to None at first commit on Wayland (#55583)
This PR fixes the default behaviour of setting `app_id` to `None` which breaks the rules based management by KWin as the first commit doesn't have the actual `app_id` and apply initially setting stops checking for the window by when it updates. 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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #53962 Release Notes: - Fixed KWin not respecting Zed's rules due to mismatch of toplevel app_id at startup |
||
|
|
f8d286c2a7 |
Fix delayed titlebar clicks on macOS 27 Beta (#59836)
## Summary macOS 27 Beta delays clicks in titlebar regions while AppKit determines whether a gesture should become a drag, single click, or double click. Zed's main workspace windows render a custom titlebar that already handles window movement via `Window::start_window_move`, so they do not need AppKit's native movable-titlebar behavior. This sets `is_movable` to `false` for the main `MultiWorkspace` windows and documents the `WindowOptions::is_movable` caveat for GPUI users with custom titlebars. ## Background The previous fix for this, #58947, used AppKit's private `_opaqueRectForWindowMoveWhenInTitlebar` SPI to mark GPUI's full-size content view as app-owned titlebar content. That fixed delayed titlebar clicks, but was later reverted in #59214 because it also affected windows that rely on AppKit's native titlebar dragging, like the settings window. This PR takes a narrower approach by only changing Zed's main custom-titlebar windows. Those windows already implement dragging explicitly via `Window::start_window_move`, so disabling AppKit's native movable-titlebar behavior fixes the macOS 27 Beta click delay without affecting other window types. Release Notes: - Fixed delayed clicks in the custom titlebar on macOS 27 Beta. |
||
|
|
e85a546880 |
gpui: Add system wake callback (#59831)
# Objective GPUI apps currently don't have a cross-platform way to react when the system wakes from sleep. ## Solution Add `Application::on_system_wake`, backed by platform hooks for macOS, Windows, and Linux. The platform listeners are registered lazily once an app installs a wake callback. ## Testing - N/A ## 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) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A |
||
|
|
ec89421dc7 |
Add non breaking glue characters as non-wrapping characters (#59775)
# Objective Fixes #57850 NBSP, NNBSP, and NBH characters were causing breaks when text is wrapped in editor when they should instead be non-breaking. ## Solution I looked for an official spec and found [Unicode Line Breaking Algorithm](https://www.unicode.org/reports/tr14/) which has these characters listed under the non-breaking ("glue") section. I opted to add these characters in manually within the logic that checks if a character is a 'word' character or not, following the pattern for how other groups of unicode characters are checked. ## Testing - Tests were added under `test_is_word_char` and `test_wrap_line` sections, and the expected behavior was verified by building zed and using these characters in the editor. - I don't think anything else needs testing now. In the future, it could make sense to make sure the entire unicode spec is followed for line breaking, as I imagine there are other obscure characters that could have this same issue. (a `unicode-linebreak` crate is imported elsewhere in the codebase but not used here) - Changes can be tested by building this commit and following the original instructions outlined in the related issue. - Tested on linux ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments (**no unsafe blocks**) - [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 <details> <summary>Before/After</summary> ### Before <img width="449" height="443" alt="before" src="https://github.com/user-attachments/assets/4d438966-1bab-46e4-a018-cd648395a1ca" /> ### After <img width="448" height="445" alt="after" src="https://github.com/user-attachments/assets/c7ce7166-9c22-4083-850f-8d8acfc42b56" /> </details> --- Release Notes: - N/A |
||
|
|
3e9408a9f4 |
gpui: Bump resvg/usvg and regression test for panic (#59704)
Bumps resvg and usvg to fix a panic when rendering some complex mermaid diagrams. Closes FR-90 --- Release Notes: - N/A or Added/Fixed/Improved ... |
||
|
|
b44f12bd4b |
gpui: Fix web examples build (#59470)
# Objective fix `cargo xtask web-examples --no-serve` error. ## Solution Building GPUI web examples for wasm failed because gpui's ordinary dev-dependencies were included in the wasm build graph. That pulled in proptest's default fork/timeout support, which depends on wait-timeout. wait-timeout does not support wasm32-unknown-unknown, so compilation failed. The a11y example also had a wasm_bindgen start function but was missing the wasm no_main crate attribute, so Rust still expected a normal main function and emitted E0601. Move gpui's proptest dev-dependency behind the non-wasm target so web example builds do not include native-only test timeout support. Add the wasm no_main crate attribute to the a11y example. Verified with: ``` cargo tree --target wasm32-unknown-unknown -p gpui -i wait-timeout cargo xtask web-examples --no-serve ``` --- Release Notes: - N/A or Added/Fixed/Improved ... Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com> |
||
|
|
6a6fcbebc4 |
Add preview to pickers and make them resizable (#59604)
Overhauls Zed's pickers to make them resizable and give them a preview. Closes #8279 ### Background The most requested Zed feature has the last year has been a [Telescope like search box](https://github.com/zed-industries/zed/issues/8279) [discussion](https://github.com/zed-industries/zed/discussions/22581). To understand why this is so popular we need to understand search can serve thee goals: - Navigation: fuzzy search is faster & easier then clicking in a file tree - Exploration: example, find a function by a word in its doc comment - Collecting: example, getting a list of functions to change The project search which shows results in a multibuffer is the perfect way to operate on a list of items. Navigation and Exploration need a lot of context around each result and offer fast navigation between them. For both of these live searching is also critical. The `telescope UI` is a picker with a preview to the right or below. It's offered in various editors and IDE's most famously Neovim (through the Telescope plugin), IntelliJ (natively), Helix (natively) and of course VScode (plugins) and it's _many_ forks. While having a UI like that for text search (our project search) is most requested the UX pattern is applied widely, from `find_all_references` to `bookmarks`. It enhances most pickers. Note that we have over 50 different picker modals! The community has tried to build something like this for Zed: - https://github.com/zed-industries/zed/pull/44530 - https://github.com/zed-industries/zed/pull/45307 - https://github.com/zed-industries/zed/pull/46478 - https://github.com/zed-industries/zed/pull/43790 These all became huge PR's that we could not merge for various reasons. This is a really hard feature to integrate in Zed! This PR got started as https://github.com/zed-industries/zed/pull/46478 and supercedes that. ### Design - Extend pickers to support an optional preview with minimal changes to the pickers themselves. - Make pickers resizable. - Complement the existing search do not replace it by having both UI's share the underlying search and allow freely switching between them. - Allow extending the preview to things other then files. - Maintain a clean design on all the pickers. ### Heigh level Implementation overview - Adds an `Option<Preview>` to `Picker` - Gives `PickerDelegate` a method to communicate a preview to the Picker - Overhaul the way pickers are drawn to allow for resizing them. Implemented on the `Shape` and `SizeBouds` structs. - Adds a high level way to draw the `footer` and `editor` so we do not need to change much to the pickers. - Adds a new text finder Picker - Adds a way to take a running search from project search and hand it to the text finder Picker and the other way round - Give the file finder a preview ### Next steps A more detailed list and how to help out will be added to the tracking issue for [Pickes with previews](https://github.com/zed-industries/zed/issues/56037) - Add more previews to more pickers! - Enable selectioning multiple items in pickers and performing actions on those - Open selected items in a multibuffer - Add a way to restore the last picker - Make popovers (picker attached to some menu) resizable as well ## 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 TODO (will be done post merge) --- Release Notes: - Added resizing via dragging to all picker modals. - Added a preview to the File finder, the preview can be to the right or below. - Added a Text finder picker with a preview as alternative project search UI. The search is shared and allowes switch between UIs while running. --------- Co-authored-by: ozacod <47009516+ozacod@users.noreply.github.com> Co-authored-by: ozacod <ozacod@users.noreply.github.com> Co-authored-by: Danilo Leal <daniloleal09@gmail.com> |
||
|
|
b5f16f69e8 |
agent_ui: Add in-thread search bar (#57231)
This is a narrower alternative to #54816, scoped to search only the currently-loaded thread, excluding tool output or thinking blocks (happy to follow up on those, see next). It uses a custom bar confined to `agent_ui` rather than `BufferSearchBar` + `SearchableItem`, avoiding the cross-crate plumbing that #54816 reached. Open as draft pending direction from @benbrandt on what scope/approach would be acceptable for in-thread search. <img width="959" height="609" alt="image" src="https://github.com/user-attachments/assets/8971e432-61d3-46db-a6a4-2bbd355089e7" /> ## What this PR does Adds a search bar to the agent panel, triggered by Ctrl+F (Cmd+F on macOS), that lets users grep the currently-loaded thread without leaving the agent panel; not cross-thread or cross-agent. - Searches visible content only: user messages, assistant message chunks, and tool-call labels. Thought blocks and rendered tool-call content (collapsed by default) are intentionally skipped so that: 1. The visible match count matches what the user sees. 2. The search experience is consistent between tool output blocks in the current Zed session, ans tool output blocks from past sessions, which are not rendered - see issue #57230 - Highlights matches inline via `Markdown::set_search_highlights` for markdown-rendered content and `Editor::highlight_background(HighlightKey::BufferSearchHighlights, …)` for past user messages (rendered through `MessageEditor`'s inner `Editor`, not through markdown). - Next/prev navigation, case/whole-word/regex toggles (same UI as `BufferSearchBar`). - Returns focus to the message editor on dismiss so the user can keep typing immediately. <details><summary>Commits (authored by Claude 4.7 Opus, max)</summary> ### Seven logical commits 1. **`agent_ui: Add in-thread search bar`** — initial implementation: bar UI, keymap bindings under `AcpThreadSearchBar` context, markdown highlight plumbing, focus-restore on dismiss. 2. **`agent_ui: Add unit tests for in-thread search`** — coverage of the matcher across entry kinds and the dismiss-clears-highlights path. 3. **`agent_ui: Limit search to visible tool-call text`** — UX fixes from manual testing: `track_focus` so `AcpThreadSearchBar` context lands in the editor's dispatch chain; red border on zero-match query; skip tool-call content (only search labels). 4. **`agent_ui: Fix Esc dispatch, smart toggle, error message, skip Thought blocks`** — round 2 of UX fixes: contribute `AcpThreadSearchBar` context from `ThreadView` when bar is visible, smart Ctrl/Cmd+F outside-the-bar focuses instead of closing, regex error message row, skip `AssistantMessageChunk::Thought`. 5. **`agent_ui: Polish thread search bar — Esc routing, user-message highlights, action forwarding`** — `search::*` action forwarders on `ThreadView`; `cx.defer` around the activate callback (fixes a double-borrow panic); `editor::actions::Cancel` interception so Esc dismisses our bar instead of escaping to the workspace's `BufferSearchBar`; user-message highlights via the inner `Editor`; muted zero-match counter; three new gpui regression tests. 6. **agent_ui: Fix Shift+Enter shadowing in thread search bar`** — capture-phase intercept of `editor::Newline*` on the bar's `bar_row` element so a base keymap binding `shift-enter` at the `Editor` context (e.g. JetBrains → `editor::NewlineBelow`) can't shadow the bar's `agent::SelectPreviousThreadMatch`. Adds a regression test that loads `default-linux.json` + `linux/jetbrains.json` and asserts `shift-enter` navigates instead of inserting a newline. 7. `agent_ui: Debounce thread search, refresh on thread changes, highlight user messages`** — last round before maintainer review: 150 ms debounce on the match rescan; subscribe to `AcpThread` updates so results/highlights/counter follow a streaming conversation live; navigate the list to the entry owning the active match; `.ok()` instead of `let _ =`; assorted cleanups; two new regression tests (`test_thread_search_refreshes_on_new_thread_entry`, `test_thread_search_scrolls_to_later_user_message_match`). </details> 8 gpui tests cover the load-bearing logic (`cargo test -p agent_ui --lib -- thread_search`). All pass. ## Manual testing Verified on Linux against `upstream/main` `bde5c0bdc9` (full `release` profile, with LTO and `codegen-units=1` built and tested at that commit). Branch since merged with `upstream/main` `2106e8c`. Of the 100 intervening upstream commits, several touch files in this diff; one produced a real conflict in `crates/agent_ui/src/conversation_view.rs` (`gpui::{...}` import block — both sides added new, non-overlapping symbols; resolved by union). - Bar opens / dismisses via Ctrl+F and Esc - Next/prev navigation via Enter / Shift+Enter / F3 / Shift+F3 / chevron buttons - Case / whole-word / regex toggles via buttons and via Alt+C / Alt+W / Alt+R (Linux) - Highlights inside past user messages render correctly on the `MessageEditor`'s inner `Editor` - query text turns red on no-match; bad regex shows error message; zero-match counter stays muted (not red) - `search::*` actions fire from outside the bar (focus in message editor) via the `ThreadView`-level forwarders - Workspace pane `BufferSearchBar` is unaffected; the two bars hold independent state - Feature looks great in light mode and dark mode, and with various themes - Navigating to a match in a past user message scrolls that message into view (its top to the viewport top) - Results update live as the agent streams new messages while the bar is open (debounced ~150 ms, same for typing) [Zed agent thread search subscribe to thread updates.webm](https://github.com/user-attachments/assets/75585fee-ba25-42ac-9dde-16c8e152fb06) <details><summary>Full manual test plan</summary> ### Setup (preconditions for every test below unless otherwise noted) 1. Launch the dev binary: `./target/release-fast/zed --user-data-dir ~/.local/share/zed-dev-feat` 2. Open the agent panel, start a thread, send 2–3 prompts so the thread contains: - At least one user prompt with a distinctive substring (e.g. `watermelon`) - At least one assistant message with a distinctive substring - At least one tool call with a known label substring - At least one collapsed Thinking block 3. In parallel: have at least one code editor open in a workspace pane (some tests cross-check that path). ### Core matching #### T-001 — Ctrl+F opens the bar with focus in query **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** With focus in the agent panel's message editor, press Ctrl+F (Linux) / Cmd+F (macOS). The search bar appears at the top of the thread view and the query input is focused. #### T-002a — Active match visually distinct from inactive matches **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** Type a query that produces ≥3 matches. The current ("active") match must be visually different from the others — different highlight color, not just position. If they look identical, this may be a theme issue (`search_active_match_background` vs `search_match_background` too close on the entry's background); note the theme. #### T-002b — User-prompt text gets inline highlight, not just match count **Status:** ✅ PASS 2026-05-15 17:15 (fix shipped 2026-05-15 16:15; regression-guarded by `test_thread_search_highlights_user_message_editor`) **Repro:** Send a user prompt containing a distinctive substring. Then search that substring. The user prompt text **must** show yellow highlight, not just be counted. The bar's matcher reads from `message.content.markdown()` but the on-screen render goes through a `MessageEditor`; the current code only highlights via `Markdown::set_search_highlights`, which misses the editor. **Notes:** Fix routes user-message matches through `Editor::highlight_background(HighlightKey::BufferSearchHighlights, …)` — the same path `Editor`'s own `SearchableItem` impl uses. `collect_markdowns` no longer pulls the user message's markdown (avoiding double-counting). The bar now maintains separate `highlighted_markdowns` and `highlighted_editors` lists for clean-up. Match-target enum (`MatchTarget::Markdown` vs `MatchTarget::Editor`) tags each match so active-vs-inactive re-paint can dispatch correctly. Pending runtime verification on next `release-fast` build. #### T-003 — Enter / Shift+Enter in bar navigates matches **Status:** ✅ PASS 2026-05-25 14:00 (verified on `release` build) **Repro:** With focus in the query, type a query with ≥3 matches. Press Enter → counter `1/N → 2/N → 3/N`. Press Shift+Enter → reverses (and no `\n`s are output in the search box). F3 / Shift+F3 same. ### Option toggles #### T-004 — Alt+C toggles case sensitivity from inside bar **Status:** ✅ PASS 2026-05-15 07:50 **Repro:** With focus in query, press Alt+C. `Aa` button toggles state; results re-filter. #### T-005 — Alt+W toggles whole-word from inside bar **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** Same as T-004, with Alt+W toggling `wd` button. #### T-006 — Alt+R toggles regex from inside bar (Linux) **Status:** ✅ PASS 2026-05-15 15:30 (fix shipped 2026-05-15 06:35) **Repro:** Press Alt+R. `.*` button toggles. **Notes:** macOS keymap (`alt-cmd-x`) left unchanged in this session — it matches the wider macOS Zed convention. #### T-006a — Tooltips on toggle buttons show their hotkey **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** Hover each toggle button (`Aa`, `wd`, `.*`). Tooltip shows action name AND keybinding (e.g. "Toggle Case Sensitive · Alt+C"). ### Error / empty states #### T-007 — Empty matches: no red border on bar input **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** Type `zzzzzzz`. Query text turns red. Counter shows `0/0`. Bar input border stays **neutral**, no red box. #### T-008 — Bad-regex error message **Status:** ✅ PASS 2026-05-15 15:30 (error renders aligned with the input) **Repro:** Switch to regex mode, type `[`. Error message appears below bar, aligned with the input. #### T-019 — Zero-match counter not colored red **Status:** ✅ PASS 2026-05-15 15:30 (fix shipped 2026-05-15 06:30) **Repro:** Type a query with no matches. The counter (`0/0`) stays muted, **not** red. MPS-parity. ### Dismissal & re-entry #### T-009 — Esc doesn't interrupt agent generation **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** Start a long prompt; while the agent is generating, open the search bar and press Esc. Bar closes, generation continues. #### T-010 — Close-X button position **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** Look at the bar. Close (X) button is on the right side, after the nav arrows (`<` `>` `1/N` `X`). NOT free-floating left of the input. #### T-011 — Ctrl+F in bar selects all query text **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** With bar open and query containing text, press Ctrl+F. All query text becomes selected (next keystroke replaces). #### T-012 — Ctrl+F outside the bar (bar already open) does not crash **Status:** ✅ PASS 2026-05-15 15:30 (fix shipped 2026-05-15 06:30; regression-guarded by `test_thread_search_select_next_from_thread_view_update_does_not_panic`) **Repro:** Bar visible, focus in the message editor (not the bar). Press Ctrl+F. Bar gets re-focused, query text is selected. **Must not crash.** **Notes:** Original crash also reproducible from Enter / Shift+Enter inside the bar after a search had matches. Fix wraps the `on_activate_match` callback's `view.update` in `cx.defer`. #### T-021 — Esc dismisses agent bar (not the unrelated workspace pane's BufferSearchBar) **Status:** ✅ PASS 2026-05-15 15:30 (fix shipped 2026-05-15 14:40; regression-guarded by `test_thread_search_editor_cancel_dismisses_bar`) **Repro:** Open a file in a workspace pane editor (e.g. `settings.json`). Open BufferSearchBar there. Switch focus to the agent panel, open agent search bar, type a query. Press Esc. **The agent bar must dismiss; the workspace pane's BufferSearchBar must remain.** **Notes:** Root cause: `Editor::cancel` in single-line mode calls `cx.propagate()`. The propagated `editor::actions::Cancel` walked past our bar all the way to `Workspace`, where `BufferSearchBar::register` had registered a workspace-wide handler that dismissed the active pane's bar. Fix: `ThreadView` now catches `editor::actions::Cancel` when the bar is visible. ### Action routing while bar is open, focus is in the message editor #### T-013 — F3 / Shift+F3 from outside the bar **Status:** ✅ PASS 2026-05-15 15:30 (Enter from outside is *expected* not to work — message editor's `enter` binding outranks. F3 is the canonical out-of-bar nav key.) **Repro:** Bar open with matches, focus in message editor. Press F3 → next match. Shift+F3 → previous. #### T-014 — Alt+C / Alt+W / Alt+R from outside the bar **Status:** ✅ PASS 2026-05-15 15:30 (fix shipped 2026-05-15 02:30; `ThreadView` forwarders for `search::ToggleCaseSensitive`, `ToggleWholeWord`, `ToggleRegex`, `FocusSearch`) **Repro:** Bar visible, focus in message editor. Alt+C/W/R toggles the bar's options and re-runs search. ### Nav buttons #### T-022 — `<` / `>` chevron buttons in the bar advance match **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** With ≥2 matches, click `<` → previous. Click `>` → next. Wraps at ends. ### Coexistence with workspace-pane buffer search #### T-015 — Ctrl+F in a workspace-pane editor still opens `BufferSearchBar` (no agent-panel takeover) **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** Focus a code editor in a workspace pane, press Ctrl+F. The pane's `BufferSearchBar` opens as before; agent panel's bar does NOT open. #### T-016 — Independent bars: agent vs workspace pane **Status:** ✅ PASS 2026-05-15 15:30 **Repro:** Have both bars open simultaneously. They hold independent state (different queries, different toggles, independent dismissal). ### Tool-call content (auto-expand on match) #### T-017 — Auto-expand collapsed tool calls on match **Status:** ⏸️ BLOCKED (not implemented; out of scope for current session) **Repro:** Have a tool call whose collapsed content contains a unique substring. Search that substring. The tool call auto-expands so the match is visible. After dismissal, the tool call collapses again unless the user manually expanded it before. #### T-018 — Auto-expand collapsed Thinking blocks on match **Status:** ⏸️ BLOCKED (not implemented; out of scope for current session) **Repro:** Same shape as T-017 for a collapsed Thinking block. #### T-019 — Streaming results automatically highlighted / live thread search **Status:** ✅ PASS 2026-06-08 **Repro:** Send prompt "Write a 5-paragraph story about a researcher who hated noise. The last paragraph should be a one-sentence: "So she moved to <name of the quietest continent on Earth>" (replace that <name> with the actual name)", then search for `Antarctica`. </details> ## Known limitations 1. (pre-existing, not from this PR): search highlights inside markdown table cells can be visually offset by a few characters in columns starting with the second. The bug lives in `crates/markdown`'s render layer - see issue #57229 2. (excluded vs. #54816 to keep the scope tight): raw tool-call input/output JSON and terminal scrollback are not indexed. 3. Navigating to a search hit located **below the fold of a very long user message** highlights the match but only scrolls the message's top into view, so the hit can stay off-screen until you scroll manually. Past user messages render through an `AutoHeight` `Editor` inside a virtualized `List`, which can't reliably drive intra-entry autoscroll the way markdown content does. User messages are usually shorter than a viewport, so this is left unaddressed. 4. Plain-text search across triple-backtick fences does not match (the fence characters live in the markdown source; regex search with explicit fence handling does). 5. The literal text "Thinking" rendered as the thought-disclosure header is not searchable (rendered chrome, not markdown source). Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - No new `unsafe` introduced; no network, file-system, or process APIs touched; only added dep is `search` (promoted from dev-dep to runtime), already used by this crate's tests; `MessageEditor::editor()` accessor widening is `pub(crate)` (in-crate only). Assessment: no new attack surface. - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) — partially; see "What I did NOT verify" above - [ ] I did not verify **macOS and Windows**. Keymap entries exist for all three platforms (`AcpThreadSearchBar` context bindings) but I only verified Linux at runtime. - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable: regexp-searching for "t.e" in a thread almost at the context limit (919k tokens) felt instant, and navigation among the 2100+ results occurred at the keyboard autorepeat rate. - [ ] Haven't measured against the 8ms / 120fps frame budget. Partially closes #39338 Release Notes: - Added in-thread search to the agent panel (Ctrl/Cmd+F) --------- Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de> |
||
|
|
21a80e7a53 |
perf: Add initial benchmark for markdown element (#59524)
## Summary This PR adds an initial markdown element renderer benchmark, so we could later expand this to benchmark search in markdown, and reparsing. This is important because the agent panel renders a lot of markdown elements, so I want to use these benchmarks to ensure our markdown element performance is good, and later expand them to include the agent panel I added a `bench_util.rs` file that has methods to generate random rust modules, this will later be used by the editor benchmarks, and is currently used by the markdown and edit_file_tool benchmarks. Finally, I made `cx.bench_renderer` also account for ready foreground tasks and poll them. This more accurately mimics gpui dispatcher. (It's not perfect, but it's good enough for a benchmark) ## 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: - N/A --------- Co-authored-by: Anant Goel <anant@zed.dev> |
||
|
|
f6512349ff |
a11y: Settings UI (#59429)
Adds: - aria attributes to most UI elements in settings UI - a new a11y API to GPUI - a fix for a GPUI keyboard focus bug ## Accesible settings UI Settings UI should now be fully accessible to users of assistive technology. **However**, there are some caveats: - accessibility features require zed to be launched with the `ZED_EXPERIMENTAL_A11Y=1` env var to be set - I have not exhaustively checked every control - There are some quite surprising keyboard focus behaviours which predate this code - The main Zed UI is still largely inaccessible, though a handful of shared components will now report themselves, but the experience is suboptimal. For anyone wishing to try out the settings UI: - make sure `ZED_EXPERIMENTAL_A11Y=1` is set - open zed - press `ctrl-,` (or `cmd+,` on a mac) to open settings UI in a separate window ## `aria_active_descendant` This is equivalent to the [`aria-activedescendant`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-activedescendant) API on the web. It allows a container to maintain focus, while indicating that one of its children should be active. Zed uses this for menus and combo boxes, for example. GPUI will report a div with `.aria_active_descendant()` as long as: - an ancestor is focused - only one descendant of the focused ancestor has `.aria_active_descendant()` Two descendants with this property where the focused node is a common ancestor is an error. ## GPUI keyboard fix GPUI will map a space or enter keypress to a div's `on_click` handler, if it exists. However, the keyboard-driven path was missing some checks that the mouseclick path has. With this PR, for an enter/space keypress to be considered a click, between the "key down" and "key up" events: - there must be no other key events - focus must not move to a different node This fixes an existing bug with combo boxes in zed where: - enter maps to `menu::Confirm` **on key down* - the menu item is selected - focus moves to the combo box - enter then triggers the combo box's `on_click` **on key up**, re-opening the menu --- Release Notes: - N/A or Added/Fixed/Improved ... --------- Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com> |
||
|
|
2df978b11c |
markdown: Optimize paint_search_highlights (#59473)
Follow up to #52502 This fixes a severe hang in the markdown preview when searching for text caused by `paint_search_highlights`. We were iterating over all lines for each highlight, and for each highlight we called `layout.line_layout_for_index` which internally would iterate over all the lines of the text layout. With this optimisation we paint all highlights in one pass. We sort the highlight ranges, iterate through the lines and only access `WrappedLineSegments` when we actually have a highlight in that line. E.g. if you copy this text (https://gist.github.com/bennetbo/e313f3023da9fec42e090177a5373152) into the editor, open the markdown preview and search for `codex` Zed Nightly will completely freeze. After this optimisation it is totally smooth even in debug mode. Release Notes: - Improved performance when searching in markdown preview |
||
|
|
a41ccd1206 |
editor: Speed up multi cursor editing (#58510)
Early draft for #32051 (multi-cursor editing is very slow, and basically hangs at high cursor counts). Opening it early like @Anthony-Eid suggested so we can agree on direction before I go further. ## Root cause Typing with a cursor on every line is mostly O(N)-per-keystroke work spread across a few places. I profiled it with `sample` and per-phase timers around `handle_input`. At 1000 cursors (~24ms before this PR): the post-edit display-map sync is ~11.8ms, the CRDT edit (`apply_local_edit`) ~3.7ms, resolving all N selections plus the per-cursor input loop ~3.5ms, the post-edit selection round-trip ~2.6ms, and `change_selections` plus transact machinery ~2.4ms. The display sync re-runs per-edit `SumTree` work through every layer even when nothing transforms (the plain-text case), and selections get re-resolved through the full display round-trip several times per keystroke. ## What this does - Display fast paths: `InlayMap::sync` (no inlays) and `WrapMap::interpolate` (no soft-wrap) skip the O(edits) transform-tree rebuild and return the passthrough snapshot, gated so a pending inlay splice or existing wraps still take the slow path. - Selection fast path: when nothing collapses buffer content (`!has_folds() && !has_replacement_blocks()`), resolve `Anchor` to `Point` to `Offset` batched and skip the per-selection display round-trip (the `todo(lw)`). - Render and autoscroll resolve only the first/last/newest selections instead of all N per frame. - A parameterized `Multi-cursor input/cursors/{1000,10000,100000}` benchmark. ## Results - Typing (`handle_input`): ~2.1x faster (24ms to 11.7ms at 1k). - Type plus two word-deletes (criterion): 29% faster (89.9 to 63.8ms) at 1k, 37% (959 to 606ms) at 10k. - Post-edit display sync alone: 11.8 to 3.8ms at 1k, 133 to 45ms at 10k. All `editor` (759), `display_map` (67), `multi_buffer` (58), and `text` (36) tests pass, and `./script/clippy` is clean. ## Direction This is ~2x, and I can get the current architecture to roughly 3.5-4.5x with a few more safe changes (hoisting the per-cursor language/editability checks, cheaper snapshot clones). Genuine VS Code numbers (~1-2us/cursor) aren't reachable while the buffer is a CRDT rope of fragments with anchor selections and a 5-layer transform stack. That would need a plain-offset cursor model and/or decoupling display layout from the edit path, which is a bigger effort I'd want to design with you. One thing I'd need your call on: `set_active_selections` sends an `UpdateSelections` collab op every keystroke (building N anchors); can that be debounced to transaction end, or do presence/follow-mode features rely on per-keystroke cursor broadcast? Release Notes: - editor: Improved multi cursor editing performance --------- Co-authored-by: Anthony Eid <anthony@zed.dev> |
||
|
|
0361eff982 |
editor: Refresh active debug line highlight on theme change (#59274)
# Objective Fixes #58736 Pause the debugger on a breakpoint, switch your theme, and the active debug line keeps its old highlight color until you step again or restart Zed. ## Solution The highlight stores a concrete color grabbed from the theme back when `go_to_active_debug_line` ran. A theme switch goes through `theme_changed`, which refreshes brackets, semantic tokens, and outline symbols but never re-applies that highlight, so it stays stale. Re-running `go_to_active_debug_line` from `theme_changed` re-resolves the color against the current theme. ## Testing Added a regression test in `debugger_ui` that stops at a debug line, swaps the theme's `editor.debugger_active_line.background`, and checks the highlight follows. It fails on `main` and passes with the fix. Also tested by hand on Windows: started a debugpy session, paused at a breakpoint, switched themes from the theme selector, and watched the active line recolor live without stepping or restarting. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [ ] 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 Paused at a breakpoint, switching themes from the theme selector. | Before | After | | --- | --- | | https://github.com/user-attachments/assets/653a7e1b-3a99-4316-b1c9-b16ed7a7a8ba | https://github.com/user-attachments/assets/22a4c876-30f2-44c5-aad9-0f860639074c | --- Release Notes: - Fixed the active debug line color not updating when switching themes while the debugger is paused ([#58736](https://github.com/zed-industries/zed/issues/58736)). --------- Co-authored-by: dino <dinojoaocosta@gmail.com> |
||
|
|
1a9b9f0d35 |
gpui_macos: Fix traffic light hitbox after repositioning (#58534)
Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [ ] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A This is a follow up to https://github.com/zed-industries/zed/pull/58169 and https://github.com/zed-industries/zed/pull/58518 after removing a bunch of unsafe usage. Before this, GPUI moved traffic lights by directly changing the native button frames inside AppKit’s existing titlebar layout and the old y-coordinate was based on the native titlebar height, so the buttons moved visually while the titlebar tracking geometry could still be based on the old layout. Now the native titlebar container is resized and repositioned to contain the traffic lights. We capture the original AppKit titlebar/button frames, resize the titlebar container to fit the requested position, move the native close/minimize/zoom buttons inside that container and update AppKit tracking areas. This keeps the visible buttons and hover/click geometry aligned. ### Before https://github.com/user-attachments/assets/77dde6cb-3fc8-4166-bc86-22cf2c93e119 ### After https://github.com/user-attachments/assets/da84ade6-ef47-4e53-ae4a-3779315773f9 --------- Co-authored-by: Yara 🏳️⚧️ <git@yara.blue> |