Commit graph

2732 commits

Author SHA1 Message Date
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
Conrad Irwin
f0f0a52793
Revert "ui: Account for padding of parent container during scrollbar layout (#27402)" (#30544)
This reverts commit 82a7aca5a6.

Release Notes:

- N/A
2025-05-12 09:47:04 +00:00
Sergei Kartsev
ae31aa2759
Fix apply buffer font features to completion tooltip (#30362) (#30519)
Closes #30362

Release Notes:

- Fixed completion tooltip to respect custom font features set in
`buffer_font_features`
2025-05-11 19:45:41 +00:00
Finn Evers
82a7aca5a6
ui: Account for padding of parent container during scrollbar layout (#27402)
Closes https://github.com/zed-industries/zed/issues/23386

This PR updates the scrollbar-component to account for padding present
in the parent container.

Since the linked issue was opened,
https://github.com/zed-industries/zed/pull/25288 improved the behaviour
so that the scrollbar does allow scrolling the entire container, however
the scrollbar thumb still does not go the entire way to the bottom. This
can be seen here:


https://github.com/user-attachments/assets/89204355-e6b8-428b-9fa9-bb614051b6fa

This happens because during layouting of the scrollbar, padding of the
parent container is not taken into account. The scrollbar thumb size is
calculated as if no padding was present.

With this change, padding is now included in the calculation, which
resolves the issue:


https://github.com/user-attachments/assets/1d4c62e0-4555-4332-a9ab-4e114684b4b3

The change here is to store the calculated content size during prepaint
_including_ padding and use this for layouting the scrollbar. This
ensures that the actual scroll max and the content size are always in
sync. Furthermore, the existing `TODO`-comment is also resolved, as we
now no longer look at the size of the last child but the actual parent
size instead.

This also removes an existing panic of the scrollbar-component in cases
where the content size was 0, which was previously not accounted for
(this never happened in practice so far, for example because of the
padding added here:

43712285bf/crates/editor/src/hover_popover.rs (L802-L809)
which prevented the container size from ever being 0).

---

Lastly, as I was wiring through the changes of the `content_size` I
noticed that some code was duplicated during the initial layouting as
well as in the click handlers. I refactored this in the second commit to
use `along` where possible as well as computing the new click offset in
one closure which can be passed to both event listeners. As always,
should any of these changes not be wanted, feel free to let me know and
I will revert these.

Looking forward to your feedback 😄 

Release Notes:

- Fixed scrollbars sometimes not scrolling all the way to the bottom.
2025-05-11 21:40:45 +02:00
peppidesu
2b249f9e68
Add support for setting font features on Linux (#27808)
Fixes #15752.
- Updated `cosmic_text` to 0.14.0
- Made a basic implementation for setting font features.

#12176 is not fixed by this PR.

Release Notes:

- Added initial support for `font_features` on Linux
2025-05-09 16:36:11 -04:00
Michael Sloan
863d7ccb6d
Fix agent panel scroll while editing a past message (#30394)
This is similar to the `block_mouse_down` method added in #20649 (which
has a very similar motivation), but is more comprehensive in stopping
mouse events. Since I want to cherry-pick this to the releases, keeping
this change just to the agent panel. In a follow-up will replace
existing use of `block_mouse_down` to instead use this.

Release Notes:

- N/A
2025-05-09 15:33:33 +00:00
张小白
89ce49d5b7
windows: Remove SmartGlobal (#30366)
Closes #29657

Using `with_clipboard_data()` to ensure that `GlobalLock` and
`GlobalUnlock` are called correctly.

Release Notes:

- N/A
2025-05-09 20:05:53 +08:00
tidely
851ab13f94
gpui: Bump blade, objc2, objc2-metal, and naga (#30347) 2025-05-09 11:40:12 +03:00
yeahyear
5249345312
chore: remove redundant word in comment (#30338)
remove redundant word in comment

Release Notes:

- remove redundant word in comment

Signed-off-by: yetyear <flite@outlook.com>
2025-05-09 07:33:20 +00:00
Max Brunsfeld
29c31f020e
Implement rendering of images with data urls in markdown (#30322)
Fixes #28266

![Screenshot 2025-05-08 at 5 08
21 PM](https://github.com/user-attachments/assets/774d2dde-3f2d-466c-8eb1-c67badbd89e4)

Release Notes:

- Added support for rendering images with data URLs in markdown. This
can show up in hover documentation provided by language servers.

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-05-08 18:26:24 -07:00
Kirill Bulatov
b4fbb9bc08
Use ESC to cancel dragging in Zed (#30318)
Closes https://github.com/zed-industries/zed/issues/11887

ESC is always captured in terminal due to 


980bfae331/crates/terminal/src/terminal.rs (L1339-L1353)

so this part is not fixed.

Otherwise, all other drags are cancelled when ESC is pressed:


https://github.com/user-attachments/assets/6e70a1e5-c244-420b-9dec-ae2ac2997a59


Release Notes:

- Allowed to use ESC to cancel dragging in Zed
2025-05-08 22:58:38 +00:00
Cole Miller
8b764a5477
Add a test for remote tool use by the agent (#30289)
- Adds a new smoke test for the use of the read_file tool by the agent
in an SSH project
- Fixes the SSH shutdown sequence to use a timer from the app's executor
instead of always using a real timer
- Changes the main executor loop for tests to advance the clock
automatically instead of panicking with `parked with nothing left to
run` when there is a delayed task

Release Notes:

- N/A
2025-05-08 16:53:04 -04:00
Jason Lee
3d737fd268
gpui: Update argument name of the from_corners method (#29968)
Release Notes:

- N/A
2025-05-06 07:17:39 +03:00
Pavel
6e28400e17
gpui: Fix a bug with Japanese romaji typing in input example (#28507)
Steps to reproduce:
* On macOS, run `input` example
* type `aaa|bbb` place caret on the place marked with |
* switch to `japanese romaji`
* press `ko`
* press left arrow

<img width="412" alt="image"
src="https://github.com/user-attachments/assets/d3c02e9b-98f9-420e-a3b7-681ba90829cd"
/>

You will get `aaa` duplicated with every arrow press.

According to [reference
implementation](https://developer.apple.com/library/archive/samplecode/TextInputView/Listings/FadingTextView_m.html#//apple_ref/doc/uid/DTS40008840-FadingTextView_m-DontLinkElementID_6)
we need to unmark text when we get empty line in `setMarkedText `
2025-05-06 00:15:41 +03:00
Lorenzo Lewis
78545a93ea
gpui: Fix typo in doc comment (#29950)
Fixes a typo in gpui docs

Release Notes:

- N/A
2025-05-05 17:05:48 -04:00
Antonio Scandurra
f891dfb358
Introduce a new StreamingEditFileTool (#29733)
This pull request introduces a new tool for streaming edits. The
short-term goal is for this tool to replace the existing `EditFileTool`,
but we want to get this out the door as soon as possible so that we can
start testing it.

`StreamingEditFileTool` is mutually exclusive with `EditFileTool`. It
will be enabled by default for anyone who has the `agent-stream-edits`
feature flag, as well as people that set `assistant.stream_edits` to
`true` in their settings.

### Implementation

Streaming is achieved by requesting a completion while the `edit_file`
tool gets called. We invoke the model by taking the existing
conversation with the agent and appending a prompt specifically tailored
for editing. In that prompt, we ask the model to produce a stream of
`<old_text>`/`<new_text>` tags. As the model streams text in, we
incrementally parse it and start editing as soon as we can.

### Evals

Note that, as part of this pull request, I also defined some new evals
that I used to drive the behavior of the recursive LLM call. To run
them, use this command:

```bash
cargo test --package=assistant_tools --features eval -- eval_extract_handle_command_output
```

Or comment out the `#[cfg_attr(not(feature = "eval"), ignore)]` macro.

I recommend running them one at a time, because right now we don't
really have a way of orchestrating of all these evals. I think we should
invest into that effort once the new agent panel goes live.

Release Notes:

- N/A

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Co-authored-by: Oleksiy Syvokon <oleksiy.syvokon@gmail.com>
2025-05-01 17:37:43 +02:00
Jason Lee
152ea04a21
chore: Move Windows dependencies to windows section (#29649)
Release Notes:

- N/A

Avoid install on macOS:

<img width="752" alt="image"
src="https://github.com/user-attachments/assets/9b13d1c5-1734-49b7-b1f0-cffbc49a3820"
/>
2025-04-30 16:24:05 +08:00
张小白
074b6965e2
gpui: Refactor PlatformKeyboardLayout (#29653)
Release Notes:

- N/A
2025-04-30 08:17:26 +00:00
张小白
edda386827
windows: Remove allow(deadcode) (#29651)
Release Notes:

- N/A
2025-04-30 15:39:19 +08:00
tidely
fde1cc78a1
gpui: Relax AssetLogger trait bounds (#29450)
Loosen trait bounds from `std::error::Error` to `std::fmt::Display`,
since it's not required for the `log::error!` macro or any other bounds.

Specify that `AssetLogger` specifically logs errors in its
documentation.

Use the `futures::TryFutureExt` trait extension to use `inspect_err`
directly on a future.

Release Notes:

- N/A
2025-04-29 12:43:54 -07:00
Mikayla Maki
4758173c33
Use image cache to stop leaking images (#29452)
This PR fixes several possible memory leaks due to loading images in
markdown files and the image viewer, using the new image cache APIs

TODO: 
- [x] Ensure this didn't break rendering in any of the affected
components.

Release Notes:

- Fixed several image related memory leaks
2025-04-29 19:30:16 +00:00
Smit Barmase
5102c4c002
gpui: Fix markdown wrapped background not correctly rendering (#29571)
Closes #29532

Fixes case where the markdown background was not rendering correctly.
This regression was introduced in
https://github.com/zed-industries/zed/pull/26454.

<img
src="https://github.com/user-attachments/assets/1e64930f-c98e-4042-a20e-46eed03293d6"
alt="image" width="400" />


Release Notes:

- Fixed an issue where markdown code blocks did not wrap correctly.
2025-04-29 04:48:24 +05:30
Ben Kunkle
ef33666701
linux(x11): Add support for pasting images from clipboard (#29387)
Closes:
https://github.com/zed-industries/zed/pull/29177#issuecomment-2823359242

Removes dependency on
[quininer/x11-clipboard](https://github.com/quininer/x11-clipboard) as
it is in [maintenance
mode](https://github.com/quininer/x11-clipboard/issues/19).

X11 clipboard functionality is now built-in to GPUI which was
accomplished by stripping the non-x11-related code/abstractions from
[1Password/arboard](https://github.com/1Password/arboard) and extending
it to support all image formats already supported by GPUI on wayland and
macos.

A benefit of switching over to the `arboard` implementation, is that we
now make an attempt to have an X11 "clipboard manager" (if available -
something the user has to setup themselves) save the contents of
clipboard (if the last copy operation was within Zed) so that the copied
contents can still be pasted once Zed has completely stopped.

Release Notes:

- Linux(X11): Add support for pasting images from clipboard
2025-04-28 13:55:26 -04:00
Finn Evers
3a1bd38503
reqwest_client: Only register proxies with valid proxy URIs (#27773)
Closes #27641

This PR fixes invalid proxy URIs being registered despite the URI not
being a valid proxy URI.

Whilst investigating #27641 , I noticed that currently any proxy URI
passed to `RequestClient::proxy_and_user_agent` will be assigned to the
created client, even if the URI is not a valid proxy URI. Given a test
as an example:

We create an URI here and pass it as a proxy to
`ReqwestClient::proxy_and_user_agent`:

https://github.com/zed-industries/zed/blob/main/crates/reqwest_client/src/reqwest_client.rs#L272-L273

In `ReqwestClient::proxy_and_user_agent`we take the proxy parameter here

9b40770e9f/crates/reqwest_client/src/reqwest_client.rs (L46)

and set it unconditionally here:

9b40770e9f/crates/reqwest_client/src/reqwest_client.rs (L62)

, not considering at all whether the proxy was successfully created
above. Concluding, we currently do not actually check whether a proxy
was successfully created, but rather whether an URI is equal to itself,
which trivially holds. The existing test for a malformed proxy URI


9b40770e9f/crates/reqwest_client/src/reqwest_client.rs (L293-L297)

does not check whether invalid proxies cause an error, but rather checks
whether `http::Uri::from_static` panics on an invalid URI, [which it
does as
documented](https://docs.rs/http/latest/http/uri/struct.Uri.html#panics).
Thus, the tests currently do not really check anything proxy-related and
invalid proxies are assigned as valid proxies.

---

This PR fixes the behaviour by considering whether the proxy was
actually properly parsed and only assigning it if that is the case.
Furthermore, it improves logging in case of errors so issues like the
linked one are easier to debug (for the linked issue, the log will now
include that the proxy schema is not supported in the logs).
Lastly, it also updates the test for a malformed proxy URI. The test now
actually checks that malformed proxy URIs are not registered for the
client rather than testing the `http` crate.

The update also initially caused the [test for a `socks4a`
proxy](9b40770e9f/crates/reqwest_client/src/reqwest_client.rs (L280C1-L282C50))
to fail. This happened because the reqwest-library introduced supports
for `socks4a` proxies in [version
0.12.13](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md#v01213).
Thus, this PR includes a bump of the reqwest library to add proper
support for socks4a proxies.

Release Notes:

- Added support for socks4a proxies.

---------

Co-authored-by: Peter Tripp <peter@zed.dev>
2025-04-28 11:12:16 -04:00
Michael Sloan
60ec55b179
Use u64 instead of usize in ElementId (#29493)
Truncation to a 32 bit `usize` could cause two distinct IDs to be
considered the same element.

Release Notes:

- N/A
2025-04-27 02:31:25 +00:00
Anthony Eid
c3177e6f5b
debugger: Fix deadlock in on_app_quit with debugger running (#29372)
This fixes a deadlock that would occur when `DapStore` had its on quit
handler called. The deadlock was caused by `DapStore` spawning on the
main thread while `App::shutdown` blocks the main thread.

We added a debug_panic in GPUI that panics if a foreground task is
spawned while the App context is shutting down. This will help tests
catch hangs in `cx.on_app_quit` calls.

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-04-25 14:15:10 -04:00
Conrad Irwin
c0f8e0f605
Fix context_stack race in KeyContextView (#29324)
cc @notpeter

Before this change we used our own copy of `cx.key_context()` when
matching.
This led to races where the context queried could be either before (or
after) the
context used in dispatching.

To avoid the race, gpui now passes out the context stack actually used
instead.

Release Notes:

- Fixed a bug where the Key Context View could show the incorrect
context,
  causing confusing results.
2025-04-23 23:34:39 -06:00
Danilo Leal
8366cd0b52
agent: Render diffs for the edit file tool (#29234)
This PR implements the `ToolCard` for the edit file tool, which allow us
to display an editor with a diff in the thread view with the changes
performed by the model.

- [x] Fix buffer sometimes displaying empty
- [x] Stop buffer from scrolling together with the thread
- [x] Fix multibuffer header sometimes appearing
- [x] Fix buffer height issue
- [x] Implement "full height" expand button
- [x] Add "Jump To File" functionality
- [x] Polish and refine styles

Release Notes:

- agent: Added diff preview cards in the thread view for edits performed
by the agent.

---------

Co-authored-by: João Marcos <marcospb19@hotmail.com>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>
Co-authored-by: Agus Zubiaga <hi@aguz.me>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-04-23 15:43:33 -03:00
Antonio Scandurra
09db31288a
Fix panic when copying smart quotes in MarkdownElement (#29285)
Release Notes:

- Fixed a panic that could sometimes happen when copying text in the
agent.
2025-04-23 15:17:27 +00:00
Mikayla Maki
3705986fac
Adjust image cache APIs to enable ElementState based APIs (#29243)
cc: @sunli829 @huacnlee @probably-neb 

I really liked the earlier PR, but had an idea for how to utilize the
element state so that you don't need to construct the cache externally.
I've updated the APIs to introduce an `ImageCacheProvider` trait, and
added an example implementation of it to the image gallery :)

Release Notes:

- N/A
2025-04-22 22:08:28 +00:00
Ben Kunkle
c231c95521
platform/blade: Improve ZED_DEVICE_ID parsing (#29235)
Closes #28533

Release Notes:

- Linux: Improved parsing of `ZED_DEVICE_ID` environment variable in an
attempt to fix some cases where it erroneously failed to parse. The
`ZED_DEVICE_ID` is now expected to always be a 4 digit hexadecimal
number (as it is in the output of `lcpci`) with an optional `0x` or `0X`
prefix.
2025-04-22 21:01:43 +00:00
Sunli
abf2b9d7d3
gpui: Add ImageCache (#27774)
Closes #27414

`ImageCache` is independent of the original image loader and can
actively release its cached images to solve the problem of images loaded
from the network or files not being released.

It has two constructors:

- `ImageCache::new`: Manually manage the cache.
- `ImageCache::max_items`: Remove the least recently used items when the
cache reaches the specified number.

When creating an `img` element, you can specify the cache object with
`Img::cache`, and the image cache will be managed by `ImageCache`.

In the example `crates\gpui\examples\image-gallery.rs`, the
`ImageCache::clear` method is actively called when switching a set of
images, and the memory will no longer continuously increase.


Release Notes:

- N/A

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
2025-04-22 13:30:21 -07:00
Matin Aniss
6caf34ab7e
gpui: Align image sprites to whole pixels (#29227)
Similar to #15822, just applies the same fix to images as they are also
affected by the same issue.

Release Notes:

- N/A
2025-04-22 17:29:03 +00:00
Bennet Bo Fenner
eca6d5a04e
agent: Support pasting images as context (#29177)
https://github.com/user-attachments/assets/d6a27b05-3590-4f40-a820-f6f99f6bd581

Release Notes:

- agent: Added support for pasting images as context

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-04-22 09:01:01 +00:00
angelrecovery
a4f5c4fef2
windows: Fix window_min_size (#29118)
Closes #29117

This makes `window_min_size` work by using the `WM_GETMINMAXINFO` window
message.


Release Notes:

- N/A

---------

Co-authored-by: 张小白 <364772080@qq.com>
2025-04-21 16:38:36 +08:00