Commit graph

2766 commits

Author SHA1 Message Date
Christian Bergschneider
40c91d5df0
gpui: Implement window_handle and display_handle for wayland platform (#28152)
This PR implements the previously unimplemented window_handle and
display_handle methods in the wayland platform. It also exposes the
display_handle method through the Window struct.

Release Notes:

- N/A
2025-05-30 15:45:03 -07:00
Aldo Funes
f8097c7c98
Improve compatibility with Wayland clipboard (#30251)
Closes #26672, #20984

Release Notes:

- Fixed issue where some applications won't receive the clipboard
contents from Zed

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-05-30 17:21:00 +00:00
Chung Wei Leong
0ee900e8fb
Support macOS Sequoia titlebar double-click action (#30468)
Closes #16527

Release Notes:

- Added MacOS titlebar double-click action

---

Unfortunately, Apple doesn't seem to make the "Fill" API public or
documented anywhere.

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2025-05-30 17:13:50 +00:00
Jason Lee
047e7eacec
gpui: Improve window.prompt to support ESC with non-English cancel text on macOS (#29538)
Release Notes:

- N/A

----

The before version GPUI used `Cancel` for cancel text, if we use
non-English text (e.g.: "取消" in Chinese), then the press `Esc` to cancel
will not work.

So this PR to change it by use `PromptButton` to instead the `&str`,
then we can use `PromptButton::cancel("取消")` for the `Cancel` button.

Run `cargo run -p gpui --example window` to test.

---

Platform Test:

- [x] macOS
- [x] Windows
- [x] Linux (x11 and Wayland)

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-05-30 15:26:27 +00:00
laizy
1d5d3de85c
gpui: Optimize the ordering update in the BoundsTree (#31025)
Release Notes:

- N/A
2025-05-30 08:23:27 -07:00
laizy
c4dbaa91f0
gpui: Fix race condition when upgrading a weak reference (#30952)
Release Notes:

- N/A
2025-05-30 08:18:25 -07:00
Cole Miller
1445af559b
Unify the tasks modal and the new session modal (#31646)
Release Notes:

- Debugger Beta: added a button to the quick action bar to start a debug
session or spawn a task, depending on which of these actions was taken
most recently.
- Debugger Beta: incorporated the tasks modal into the new session modal
as an additional tab.

---------

Co-authored-by: Julia Ryan <juliaryan3.14@gmail.com>
Co-authored-by: Julia Ryan <p1n3appl3@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Mikayla <mikayla@zed.dev>
2025-05-29 21:33:52 -04:00
Michael Sloan
8aef64bbfa
Remove block_mouse_down in favor of stop_mouse_events_except_scroll (#30401)
This method was added in #20649 to be an alternative of `occlude` which
allows scroll events. It seems a bit arbitrary to only stop left mouse
downs, so this seems like it's probably an improvement.

Release Notes:

- N/A
2025-05-29 22:07:34 +00:00
Michael Sloan
9086784038
gpui: Support hitbox blocking mouse interaction except scrolling (#31712)
tl;dr: This adds `.block_mouse_except_scroll()` which should typically
be used instead of `.occlude()` for cases when the mouse shouldn't
interact with elements drawn below an element. The rationale for
treating scroll events differently:

* Mouse move / click / styles / tooltips are for elements the user is
interacting with directly.
* Mouse scroll events are about finding the current outer scroll
container.

Most use of `occlude` should probably be switched to this, but I figured
I'd derisk this change by minimizing behavior changes to just the 3 uses
of `block_mouse_except_scroll`.

GPUI changes:

* Added `InteractiveElement::block_mouse_except_scroll()`, and removes
`stop_mouse_events_except_scroll()`

* Added `Hitbox::should_handle_scroll()` to be used when handling scroll
wheel events.

* `Window::insert_hitbox` now takes `HitboxBehavior` instead of
`occlude: bool`.

    - `false` for that bool is now `HitboxBehavior::Normal`.

    - `true` for that bool is now `HitboxBehavior::BlockMouse`.
    
    - The new mode is `HitboxBehavior::BlockMouseExceptScroll`.

* Removes `Default` impl for `HitboxId` since applications should not
manually create `HitboxId(0)`.

Release Notes:

- N/A
2025-05-29 21:41:15 +00:00
tongjicoder
31d908fc74
Remove redundant words in comments (#31512)
remove redundant word in comment


Release Notes:

- N/A

Signed-off-by: tongjicoder <tongjicoder@icloud.com>
2025-05-27 23:01:31 +00:00
张小白
ba6b5a59f9
windows: Fix title bar not responsing (#31532)
Closes #31431

Release Notes:

- N/A
2025-05-27 16:43:48 +00:00
Michael Sloan
649072d140
Add a live Rust style editor to inspector to edit a sequence of no-argument style modifiers (#31443)
Editing JSON styles is not very helpful for bringing style changes back
to the actual code. This PR adds a buffer that pretends to be Rust,
applying any style attribute identifiers it finds. Also supports
completions with display of documentation. The effect of the currently
selected completion is previewed. Warning diagnostics appear on any
unrecognized identifier.


https://github.com/user-attachments/assets/af39ff0a-26a5-4835-a052-d8f642b2080c

Adds a `#[derive_inspector_reflection]` macro which allows these methods
to be enumerated and called by their name. The macro code changes were
95% generated by Zed Agent + Opus 4.

Release Notes:

* Added an element inspector for development. On debug builds,
`dev::ToggleInspector` will open a pane allowing inspecting of element
info and modifying styles.
2025-05-26 17:43:57 +00:00
tidely
2e62f16149
gpui: Apply cfg at compile time (#31428)
- Use compile time `cfg` macro instead of a runtime check
- Use `Modifiers` instead of a bunch of `bool` when parsing a
`Keystroke`.

Release Notes:

- N/A
2025-05-26 13:34:04 +00:00
Floyd Wang
c73af0a52f
gpui: Add more shapes for PathBuilder (#30904)
- Add `arc` for drawing elliptical arc.
- Add `polygon` support.

<img width="1136" alt="image"
src="https://github.com/user-attachments/assets/97032b02-e6ff-4985-a587-3689500bfd56"
/>

Release Notes:

- N/A
2025-05-26 12:49:42 +03:00
tidely
8b59776320
gpui: Remove unnecessary String (#31314)
Replaces a `String` with `&'static str`

Release Notes:

- N/A
2025-05-26 11:17:03 +03:00
Michael Angerman
df98d94a24
gpui: Activate the window example along with the Quit action (#30790)
Make the gpui examples more consistent by activating the window upon
startup.
Most of the examples have 

```rust
activate(true) 
```

so this one should as well.

Make it easier to exit the example with the `cmd-q` KeyBinding

Release Notes:

- N/A
2025-05-26 10:10:35 +03:00
waffle
c7da6283cc
gpui: Fix typo in doc comment (#31397)
Release Notes:

- N/A
2025-05-26 07:59:51 +03:00
Michael Sloan
ab59982bf7
Add initial element inspector for Zed development (#31315)
Open inspector with `dev: toggle inspector` from command palette or
`cmd-alt-i` on mac or `ctrl-alt-i` on linux.

https://github.com/user-attachments/assets/54c43034-d40b-414e-ba9b-190bed2e6d2f

* Picking of elements via the mouse, with scroll wheel to inspect
occluded elements.

* Temporary manipulation of the selected element.

* Layout info and JSON-based style manipulation for `Div`.

* Navigation to code that constructed the element.

Big thanks to @as-cii and @maxdeviant for sorting out how to implement
the core of an inspector.

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Co-authored-by: Federico Dionisi <code@fdionisi.me>
2025-05-23 23:08:59 +00:00
tidely
fbc922ad46
Reduce allocations (#31223)
Release Notes:

- N/A
2025-05-23 14:25:17 +03:00
张小白
ee4e43f1b6
linux: Fix wrong keys are reported when using German layout (#31193)
Part of #31174

Because the keyboard layout parameter wasn’t set correctly, characters
don’t show up properly when using the German layout at launch.

To reproduce:
Switch to the German layout, launch Zed, and press the `7` key. it
should output `7`, but instead it outputs `è`.


Release Notes:

- N/A
2025-05-22 14:47:23 +00:00
Finn Evers
2044426634
gpui: Improve displayed keybinds shown in macOS application menus (#28440)
Closes #28164

This PR adresses inproper keybinds being shown in MacOS application
menus. The issue arises because the keybinds shown in MacOS application
menus are unaware of keybind contexts (they are only ever updated [on a
keymap-change](6d1dd109f5/crates/zed/src/zed.rs (L1421))).
Thus, using the keybind that was added last in the keymap can result in
incorrect keybindings being shown quite frequently, as they might belong
to a different context not generally available (applies the same for the
default keymap as well as for user-keymaps).

For example, the linked issue arises because the keybind found last in
the iterator is
6d1dd109f5/assets/keymaps/vim.json (L759),
which is not even available in most contexts (and, additionally, the `e`
of `escape` is rendered here as a keybind which seems to be a seperate
issue).

Additionally, this would result in inconsistent behavior with some
Vim-keybinds. A vim-keybind would be used only when available but
otherwise the default binding would be shown (see `Undo` and `Redo` as
an example below), which seems inconsistent.

This PR fixes this by instead using the first keybind found in keymaps,
which is expected to be the keybind available in most contexts.
Additionally, this allows rendering some more keybinds for actions which
vim-keybind cannot be displayed (Find In Project for example) .This
seems to be more reasonable until [this related
comment](6d1dd109f5/crates/gpui/src/keymap.rs (L199-L204))
is resolved.

This includes a revert of #25878 as well. With this change, the change
made in #25878 becomes obsolete and would also regress the behavior back
to the state prior to that PR.

|  | `main` | This PR |
| --- | --- | --- |
| Edit-menu | <img width="220" alt="main_edit"
src="https://github.com/user-attachments/assets/9f793b64-80b6-4a5b-b7e5-628f0d552166"
/> | <img width="220" alt="PR_edit"
src="https://github.com/user-attachments/assets/bccb444c-7a49-41d5-9377-d90b1639a3ed"
/> |
| View-menu | <img width="214" alt="main_view"
src="https://github.com/user-attachments/assets/0e6a6632-df02-4883-9f5a-facb4d0263b5"
/> | <img width="214" alt="PR_view"
src="https://github.com/user-attachments/assets/14600ece-fcaa-447a-94ef-4fa350eca49c"
/> |


Release Notes:

- Improved keybinds displayed for actions in MacOS application menus.
2025-05-22 09:51:51 -04:00
smit
7450b788f3
editor: Prevent overlapping of signature/hover popovers and context menus (#31090)
Closes #29358

If hover popovers or signature popovers ever clash with the context menu
(like code completion or code actions), they find the best spot by
trying different directions around the context menu to show the popover.
If they can’t find a good spot, they just overlap with the context menu.

Not overlapping state:
<img width="350" alt="image"
src="https://github.com/user-attachments/assets/2f1bdc4c-eb01-405c-b5fb-eb28eadc9957"
/>

Overlapping case, moves popover to bottom of context menu:
<img width="350" alt="image"
src="https://github.com/user-attachments/assets/3ce4be23-7701-4711-b604-5e29682360e1"
/>

Overlapping case, moves popover to right of context menu:
<img width="350" alt="image"
src="https://github.com/user-attachments/assets/60d47518-e412-4d64-9d17-a69a17248bdf"
/> <img width="350" alt="image"
src="https://github.com/user-attachments/assets/2a3de176-7443-46d8-99d1-b2973a0ffaa6"
/>

Overlapping case, moves popover to left of context menu:
<img width="350" alt="image"
src="https://github.com/user-attachments/assets/015b799b-8c6e-4405-aee6-e205d4caebec"
/>

Overlapping case, moves popover to top of context menu:
<img width="350" alt="image"
src="https://github.com/user-attachments/assets/fbd03d84-9a49-44eb-846b-a9852d2ff43e"
/>

Release Notes:

- Fixed an issue where hover popovers or signature popovers would
overlap with existing opened completion or code actions context menus.
2025-05-21 18:45:00 +05:30
Kirill Bulatov
16366cf9f2
Use anyhow more idiomatically (#31052)
https://github.com/zed-industries/zed/issues/30972 brought up another
case where our context is not enough to track the actual source of the
issue: we get a general top-level error without inner error.

The reason for this was `.ok_or_else(|| anyhow!("failed to read HEAD
SHA"))?; ` on the top level.

The PR finally reworks the way we use anyhow to reduce such issues (or
at least make it simpler to bubble them up later in a fix).
On top of that, uses a few more anyhow methods for better readability.

* `.ok_or_else(|| anyhow!("..."))`, `map_err` and other similar error
conversion/option reporting cases are replaced with `context` and
`with_context` calls
* in addition to that, various `anyhow!("failed to do ...")` are
stripped with `.context("Doing ...")` messages instead to remove the
parasitic `failed to` text
* `anyhow::ensure!` is used instead of `if ... { return Err(...); }`
calls
* `anyhow::bail!` is used instead of `return Err(anyhow!(...));`

Release Notes:

- N/A
2025-05-20 23:06:07 +00:00
Ben Kunkle
eb318c1626
Revert "linux(x11): Add support for pasting images from clipboard (#29387)" (#31033)
Closes: #30523

Release Notes:

- linux: Reverted the ability to paste images on X11, as the change
broke pasting from some external applications
2025-05-20 13:05:24 -04:00
Jason Lee
65e751ca33
Revert "gpui: Fix shape_text split to support \r\n" (#31031)
Reverts zed-industries/zed#31022

Sorry @mikayla-maki, I found that things are more complicated than I
thought.

The lines returned by shape_text must maintain the same length as all
the original characters, otherwise the subsequent offset needs to always
consider the difference of `\r\n` or `\n` to do the offset.

Before, we only needed to add +1 after each offset after the line, but
now we need to consider +1 or +2, which is much more complicated.
2025-05-20 16:01:47 +00:00
Jason Lee
b7d5e6480a
gpui: Fix shape_text split to support \r\n (#31022)
Release Notes:

- N/A

---

Today I check the shape_text result on Windows, I get:

<img width="409" alt="屏幕截图 2025-05-20 222908"
src="https://github.com/user-attachments/assets/3ee93911-3de1-4e01-9433-00c626fc2369"
/>

Here the `shape_text` split logic I think it should use `lines` method,
not `split('\n')`, the newline on Windows is `\r\n`.
2025-05-20 14:53:50 +00:00
Jason Lee
0fa9f05313
gpui: Fix update_window to borrow_mut will crash on Windows (#24545)
Release Notes:

- N/A

---


When we use `window_handle` to draw WebView on Windows, this will crash
by:

This error caused by when used WebView2.

```
thread 'main' panicked at crates\gpui\src\app\async_context.rs:91:28:
already borrowed: BorrowMutError
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at library\core\src\panicking.rs:221:5:
panic in a function that cannot unwind
```

Try this https://github.com/tauri-apps/wry/pull/1383 on Windows can
replay the crash.

In fact, we had done [a similar fix around August last
year](https://github.com/huacnlee/zed/pull/6), but we used the unsafe
method to avoid crashes in that version, we felt that it was not a good
change, so we do not make PR.

Today @sunli829 thought about it again and changed the method. Now using
`try_borrow_mut` is similar to the previous `borrow_mut`.


691de6b4b3/crates/gpui/src/app.rs (L70-L78)

I have tested to start Zed by those changes, it is looks no problem.

Co-authored-by: Sunli <scott_s829@163.com>
2025-05-20 22:17:16 +08:00
Michael Angerman
e9c9a8a269
gpui: Correct the image id in the example image_loading (#30990)
The image id "image-1" already exists so the id should be "image-4"

Release Notes:

- N/A
2025-05-20 10:36:41 +03:00
Mikayla Maki
315321bf8c
Add end of service notifications (#30982)
Release Notes:

- N/A

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-05-20 00:20:00 +00:00
laizy
70b0c4d63d
gpui: Replace Mutex with RefCell for SubscriberSet (#30907)
`SubscriberSet` is `!Send` and `!Sync` because the `active` field of
`Subscriber` is `Rc`.

Release Notes:

- N/A
2025-05-19 11:08:04 +02:00
Conrad Irwin
ff0060aa36
Remove unnecessary result in line shaping (#30721)
Updates #29879

Release Notes:

- N/A
2025-05-16 23:48:36 +02:00
Nate Butler
e26620d1cf
gpui: Add a standard text example (#30747)
This is a dumb first pass at a standard text example. We'll use this to
start digging in to some text/scale rendering issues.

There will be a ton of follow-up features to this, but starting simple.

Release Notes:

- N/A
2025-05-16 17:35:44 +02:00
张小白
98aefcca83
windows: Some refactor (#30826)
Release Notes:

- N/A
2025-05-16 14:14:42 +00:00
Ben Kunkle
1d043b37fb
askpass: Workaround rust lang 69343 (#30774)
Closes #ISSUE

Work around https://github.com/rust-lang/rust/issues/69343 in askpass

Release Notes:

- linux: Fixed an issue with askpass where the Zed binary path would be incorrect after an auto-update is installed
but not yet applied
2025-05-16 05:04:36 -04:00
Piotr Osiewicz
0f17e82154
chore: Bump Rust to 1.87 (#30739)
Closes #ISSUE

Release Notes:

- N/A
2025-05-15 22:28:52 +00:00
张小白
4b7b5db58c
windows: Remove unnecessay helper function (#30764)
Release Notes:

- N/A
2025-05-15 14:22:04 +00:00
张小白
58ba833792
windows: Fix keystroke (#30753)
Closes #22656

Part of #29144, this PR completely rewrites the key handling logic on
Windows, making it much more consistent with how things work on macOS.
However, one remaining issue is that on Windows, we should be using
`Ctrl+Shift+4` instead of `Ctrl+$`. That part is expected to be
addressed in #29144.


Release Notes:

- N/A
2025-05-15 20:49:06 +08:00
CharlesChen0823
b2fc4064c0
gpui: Avoid dereferencing null pointer (#30579)
as
[comments](https://github.com/zed-industries/zed/pull/24545#issuecomment-2872833658),
I really don't known why, But IMO, add this code is not harm.

If you think this is not necessary, can close.

Release Notes:

- N/A
2025-05-15 09:50:58 +02:00
Kirill Bulatov
fcfe4e2c14
Reuse existing language servers for invisible worktrees (#30707)
Closes https://github.com/zed-industries/zed/issues/20767

Before:


https://github.com/user-attachments/assets/6438eb26-796a-4586-9b20-f49d9a133624


After:



https://github.com/user-attachments/assets/b3fc2f8b-2873-443f-8d80-ab4a35cf0c09



Release Notes:

- Fixed external files spawning extra language servers
2025-05-14 16:24:17 +00:00
Finn Evers
4280bff10a
Reapply "ui: Account for padding of parent container during scrollbar layout" (#30577)
This PR reapplies #27402 which was reverted in
https://github.com/zed-industries/zed/pull/30544 due to the issue
@ConradIrwin reported in
https://github.com/zed-industries/zed/pull/27402#issuecomment-2871745132.
The reported issue is already present on main but not visible, see
https://github.com/zed-industries/zed/pull/27402#issuecomment-2872546903
for more context and reproduction steps.

The fix here was to move the padding for the hover popover up to the
parent container. This does not fix the underlying problem but serves as
workaround without any disadvantages until a better solution is found. I
would currently guess that the underlying issue might be related to some
rem-size calculations for small font sizes or something similar (e.g.
https://github.com/zed-industries/zed/pull/22732 could possibly be
somewhat related).

Notably, the fix here does not cause any difference in layouting (the
following screenshots are actually distinct images), yet fixes the
problem at hand.

### Default font size (`15px`) 

| `main` | This PR |
| --- | --- |
|
![main_large](https://github.com/user-attachments/assets/66d38827-9023-4f78-9ceb-54fb13c21e41)
|![PR](https://github.com/user-attachments/assets/7af82bd2-2732-4cba-8d4b-54605d6ff101)
|

### Smaller font size (`12px`)

| `main` | This PR |
| --- | --- |
|
![pr_large](https://github.com/user-attachments/assets/d43be6e6-6840-422c-baf0-368aab733dac)
|
![PR](https://github.com/user-attachments/assets/43f60b2b-2578-45d2-bcab-44edf2612ce2)
|

Furthermore, for the second scenario, the popover would be scrollable on
main. As there is no scrollbar in the second image for this PR, this no
longer happens with this branch.


Release Notes:

- N/A
2025-05-14 13:26:14 +02:00
张小白
22f76ac1a7
windows: Remove unneeded ranges for replace_and_mark_text_in_range (#30668)
Release Notes:

- N/A
2025-05-14 07:26:10 +00:00
Michael Sloan
25cc05b45c
Use Vec instead of SmallVec for glyphs field of ShapedRun (#30664)
This glyphs field is usually larger than 8 elements, and SmallVec is not
efficient when it cannot store the value inline.

This change also adds precise glyphs run preallocation in some places
`ShapedRun` is constructed.

Release Notes:

- N/A
2025-05-14 07:02:38 +00:00
Michael Sloan
6fc9036063
Multi-glyph text runs on Linux (#30660)
Release Notes:

- N/A
2025-05-13 22:10:35 +00:00
Michael Sloan
71ea7aee3b
Misc optimization/cleanup of use of Cosmic Text on Linux (#30658)
* Use cosmic_text `metadata` attr to write down the `FontId` from the
input run to avoid searching the list of fonts when laying out every
glyph.

* Instead of checking on every glyph if `postscript_name` is an emoji
font, just store `is_known_emoji_font`.

* Clarify why `font_id_for_cosmic_id` is used, and when its use is
valid.

Release Notes:

- N/A
2025-05-13 21:20:41 +00:00
张小白
7aabbb0426
windows: Properly handle dead char (#30629)
Release Notes:

- N/A
2025-05-13 12:50:21 +00:00
张小白
9426caa061
windows: Implement keyboard_layout_change (#30624)
Part of #29144

Release Notes:

- N/A
2025-05-13 18:02:56 +08:00
张小白
29da105dd5
windows: Fix ModifiersChanged event (#30617)
Follow-up #30574

Release Notes:

- N/A
2025-05-13 09:05:24 +00:00
Michael Sloan
986d271ea7
Fix panic in linux text rendering + refactor to avoid similar errors (#30601)
See #27808. `font_id_for_cosmic_id` was another path updated
`loaded_fonts_store` but did not push to `features_store`. Solution is
just to have one `Vec` with fields rather than relying on the indices
matching up

Release Notes:

- N/A
2025-05-12 21:41:14 +00:00
张小白
33c896c23d
windows: Fix ctrl-click open hovered URL (#30574)
Closes #30452

Release Notes:

- N/A
2025-05-12 22:15:50 +08:00
william341
634b275931
gpui: Fix cosmic-text raster_bounds calculation (#30552)
Closes #30526.

This PR makes the CacheKey used by raster_bounds and rasterize_glyph the
same, as they had not used the same sub pixel shift previously. Fixing
this resolves both the alignment and text-rendering issues introduced in
`ddf8d07`.

Release Notes:

- Fixed text rendering issues on Linux.
2025-05-12 11:10:40 +00:00