Commit Graph

5315 Commits

Author SHA1 Message Date
xdBronch 8385157b2f editor: Fix off by one in Open Docs action (#64317)
# Objective

using `editor: open docs` never chose the local file even when it
existed, found it was because this was slicing off the leading `/` which
gave an invalid path

## Solution

slice the URI correctly to preserve the path

## Testing

tested by using `editor: open docs` in my project before and after
running `cargo doc`, before it went to doc.rs, after it opened the local
docs file

## 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:

- fixed opening local documentation when using `editor: open docs`

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-10-05 08:21:11 +00:00
Rani 2117a376b9 editor: Reuse tab point cursor state across calls (#64409)
Follow-up to #58510 and #60605 for #32051. This is the `TabMap::sync`
cursor reuse @Anthony-Eid asked for in
https://github.com/zed-industries/zed/issues/32051#issuecomment-4781437473,
and it resolves the `todo(lw): Implement TabPointCursor properly`.

## What was slow

`TabPointCursor::map` was stateless: every call built a new fold chunk
iterator at column 0 of the row (several tree descents plus a rope seek)
and rescanned the row. `TabMap::sync` makes four of those calls per
edit, plus a fifth chunk iterator per edit to look for tabs after the
edit. With one cursor per line that is five iterator constructions per
cursor per keystroke.

Temporary timers around each layer in `DisplayMap::sync_through_wrap`
(not committed) showed the tab map was essentially the whole display
sync on the multi-cursor path. Per sync, `Multi-cursor input` bench,
Apple Silicon:

| layer | 1k cursors | 10k cursors |
|---|---|---|
| `InlayMap::sync` | 4 µs | 20 µs |
| `FoldMap::read` | 27 µs | 204 µs |
| `TabMap::sync` | 3,856 µs | 46,160 µs |
| `WrapMap::sync` | 27 µs | 190 µs |

## What this does

- `TabPointCursor` keeps its `TabStopCursor` and tab expansion state
between calls. A later column on the same row continues the scan. A
nearby later row is reached by walking the chunk `newlines` bitmaps
(bounded by a chunk budget). Anything else (a far row, an earlier point,
`reset()`) seeks the existing chunk iterator, so out-of-order input
stays correct and only costs a seek. `reset()` was a no-op that
`DisplayPointConverter` already relied on; it now forces a re-seek.
- `expand_tabs` takes the cursor and expansion state by reference, so
the cursor and the one-off `fold_point_to_tab_point` share one code
path. The one-off path builds its `TabStopCursor` directly as before.
- `TabMap::sync` maps the merged edits through one cursor per snapshot.
The points are non-decreasing within each snapshot.
- `TabMap::sync` seeks a single fold chunk iterator when looking for
tabs after each edit, and stops at the first newline instead of
converting the next row's start to an offset.

No callers change. `BlockMap::sync`, `BlockMap::spacer_blocks` and
`DisplayPointConverter` pick up the stateful cursor as is; the companion
side of `spacer_blocks` and `columnar_selection` keep using the
stateless `fold_point_to_tab_point` because they walk backward.

## Results

`TabMap::sync` per sync, same timers:

| | 1k cursors | 10k cursors |
|---|---|---|
| before | 3,856 µs | 46,160 µs |
| cursor reuse in the mapping pass | 1,989 µs | 23,718 µs |
| plus the shared chunk iterator | 1,380 µs | 16,205 µs |

The bench does three edits per iteration, so this removes roughly 90 ms
of a ~550 ms iteration at 10k cursors. The whole-bench number is noisy
at `sample_size = 10` (two runs of unmodified `main` gave 549 ms and 671
ms on my machine), which is why I am reporting the per-layer timers; the
criterion comparison against a saved `main` baseline was -9.6% at 10k (p
= 0.00) and within noise at 1k.

`To tab point/to_tab_point/1024` (one-off conversion) is unchanged:
412.0 ns before, 412.3 ns after (p = 0.10).

What is left in `TabMap::sync` is mostly the six `FoldOffset ->
FoldPoint` conversions per edit, which could get the same cursor
treatment in a follow-up. After this change the inlay, fold, tab and
wrap sync together are about 10% of the multi-cursor bench at 10k
cursors; the rest is outside them.

## Tests

The first commit adds tests only, and they pass on unmodified `main`:

- `test_random_tab_map_sync` drives buffer, inlay and fold mutations
plus tab size changes through `TabMap::sync` and checks the returned
`TabEdit`s by applying them to the previous tab text. Nothing asserted
on `TabEdit` ranges before, and `test_random_tabs` never calls `sync`.
- `test_tab_map_sync_edits` asserts the exact expanded edit ranges for a
small case.
- `test_random_tab_point_cursor` maps sorted, repeated, and then
unordered fold points (including columns past the end of the row and
multibyte text) through a single cursor with a randomized scan budget,
and compares against both the oracle and `fold_point_to_tab_point`.

All three pass at `ITERATIONS=5000`, as do `test_random_tabs` and
`test_to_tab_point_random`. `cargo test -p editor` passes (1144 tests)
and `./script/clippy -p editor` is clean.

One thing I ran into: with `MultiBuffer::build_random` the sync test
fails at seed 4882 on unmodified `main` too, because `FoldMap` reports a
fold edit whose old range does not cover text that a surviving fold
re-folds after excerpts are replaced. That is unrelated to the tab map,
so the test uses a singleton buffer. Filed as #64444.

Release Notes:

- Improved multi cursor editing performance
2026-10-05 07:44:07 +00:00
Kirill Bulatov ad4512a2e5 Fix tab double click (#65159)
Closes https://github.com/zed-industries/zed/issues/65140

Also return back the extra actions: for that, reverts part of
https://github.com/zed-industries/zed/pull/65081 and re-implements the
actions properly.


https://github.com/user-attachments/assets/04570ff5-08cb-4414-a386-b1b5b6660f47

Release Notes:

- N/A (Nightly only)
2026-10-05 07:20:42 +00:00
Josh Kent 80ee0a3563 markdown_preview: Add Show Source to preview tab menu (#65081)
## Summary

Markdown files can now open in preview by default, but there's no
discoverable way back to the raw source.
`markdown::CloseAndReturnToEditor` exists (`cmd-shift-v` /
`ctrl-shift-v`), but nothing in the UI points to it.

This adds a "Show Source" entry to the preview tab's context menu that
triggers that action.

Tab menu entries that dispatch actions only work on the active tab.
Inactive tabs aren't rendered, so they aren't in the dispatch tree and
never receive the action. Because of that:

- "Show Source" only appears when the preview is the active tab.
- The editor's "Open Markdown Preview" and "Open SVG Preview" entries
had the same problem, so they're now hidden on inactive tabs too.

## Testing

- `cargo test -p markdown_preview`
- `./script/clippy -p markdown_preview -p editor`
- Manually verified on macOS:
- Right-click the active Markdown preview tab → "Show Source" closes the
preview and focuses the source editor.
- Right-click an inactive preview tab or inactive Markdown editor tab →
no preview entries are shown.

To try it: open any `.md` file in preview, right-click the preview tab,
choose "Show Source".

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Added a "Show Source" option to the Markdown preview tab context menu.
- Fixed "Open Markdown Preview" and "Open SVG Preview" appearing in the
tab context menu of inactive tabs, where they had no effect.
2026-10-03 02:35:10 +00:00
Yue Fei 90731bdec0 editor: Fix movement mismatch between minimap thumb and cursor (#62087)
# Objective

Fixes #44824

This bug results from an incorrect mathematical derivation of the
`pixels_per_line` calculation formula. The complete derivation is too
lengthy to include here, so it is provided in a separate comment below.

This PR does the same thing as #60080, but it is a refined version of
it.

## Solution

Replace the previous incorrect calculation formula with the correct one.

## Testing

These changes are manually tested on my computer and all worked as
expected.

## 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 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

## Showcase

This recording shows the behavior in short document environment:


https://github.com/user-attachments/assets/2e5e7aec-ccf2-47c3-a046-e7f668bdb6c0

While this one shows the behavior in long document environment:


https://github.com/user-attachments/assets/e5809c81-4cfb-45f9-8ec7-051a487bd6f7

It's apparent that the minimap thumb moves closely with the cursor in
both environments.

---

Release Notes:

- Fixed movement mismatch between minimap thumb and cursor.

---------

Co-authored-by: Finn Evers <finn@zed.dev>
2026-10-02 10:08:12 +00:00
Manoj sk 0bdc70c2eb editor: Fix cmd-click doing nothing on a symbol named after its file (#64892)
## Summary

Cmd-clicking a symbol whose name matches its own file did nothing at all
— no
navigation, no references list, no toast.

When Zed sees a word that might be a file path, it tries appending the
language's
file extensions before giving up, so the word `TestClass` matches a file
named
`TestClass.php`. A symbol named after the file it lives in therefore
produces two
hover links: a definition pointing at the cursor itself, and a file link
pointing
at the buffer already open.

The definition was correctly dropped as a self-link, but the file link
survived.
Cmd-click then "navigated" by re-opening the current file and returned
`Navigated::Yes`, which suppressed the go-to-definition fallback — so
`textDocument/references` was never sent and the click silently did
nothing.

This applies the same self-link rule to file links: drop one that
resolves to the
buffer we are already in, and leave every other file link alone so
cmd-clicking a
path in a comment still opens it.

Closes #64063


## Testing

Two tests, one for each half of the rule:

- `test_cmd_click_on_file_link_to_current_file_falls_back_to_references`
— fails if
  the fix is reverted
- `test_cmd_click_on_file_link_to_another_file_still_navigates` — fails
if the fix
is narrowed to dropping all file links, which resolves the bug but
breaks
  cmd-click on ordinary paths in comments

Verified both go red with the fix reverted.

Manually verified on macOS with the PHP reproduction from the issue:
cmd-clicking
`TestClass` in `TestClass.php` now opens the references list, and
cmd-clicking a
file path in a comment still opens that file.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist). — no UI
changes
- [x] Tests cover the new or changed behavior.


Release Notes:

- Fixed cmd-click doing nothing on a symbol whose name matches its file
name



https://github.com/user-attachments/assets/72550d00-f668-4727-bdde-1456f0b50e66
2026-09-30 19:11:02 +00:00
HuaGu-Dragon 9874229eb7 lsp: Fix some inlay_hints' anchor does not have right bias (#64791)
## Summary

Some inlay hints currently use an incorrect bias, especially hints whose
LSP `kind` is `None`. The previous implementation used a simple rule:

- `Parameter` used `anchor_before`
- all other hint kinds used `anchor_after`

This caused some hints to be rendered at the wrong position

| Scenario | `main` | this PR |
|---|---|---|
| Cursor at EOL after `}` | `{}\| // fn foo` | `{}\| // fn foo` |
| Cursor after `&` | `&\|'_ str` | `&'_ \|str` |
| Type `bar` after `foo` | `foobar\|<'_>(` | `foobar\|<'_>(` |

The second scenario is improved

Unfortunately, `BindingMode` and `reborrow` hints are still not fixed.
Their positions may still be incorrect both before and after this change

## Solution

A previous
[review](https://github.com/zed-industries/zed/pull/64593#discussion_r4082517910)
suggested using padding to determine the bias. This approach works;
however, we can do even better by determining the anchor direction based
on the hint kind and the word surrounding the hint position, allowing us
to make better use of rangeExclusiveHints and other hints whose padding
is not set on both the left and right sides. This is similar to how [VS
Code](https://github.com/microsoft/vscode/blob/c3cbcba676f18ba2d0281d10d43b7ccd63db9a69/src/vs/editor/contrib/inlayHints/browser/inlayHints.ts#L115)
handles it

Therefore, the LSP kind alone is not sufficient to distinguish prefix
hints from suffix hints in every case. This PR uses `surrounding_word`
as a heuristic: it takes the greater of `prev` and `next` as the word
kind, so a hint is treated as a suffix hint when the previous
character’s kind is greater than or equal to the next character’s kind;
otherwise, it is treated as a prefix hint. `None` covers both
directions, such as an RA lifetime after `&` and a `ClosingBrace` after
`}`

## Testing

This PR adds tests for the three scenarios mentioned in the previous
review
And add a test for multiple hints sharing the same LSP position. When
the per-hint rules conflict, all hints should use the same bias
(`anchor_after`), consistent with the main rule

## Showcase

<details>
  <summary>Click to view showcase</summary>


https://github.com/user-attachments/assets/6d48c78a-e5f6-4277-9fd6-73cf6f674a73


https://github.com/user-attachments/assets/7eace941-9bea-4718-b51f-1facf70e9bc3

</details>

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed incorrect anchor bias for some inlay hints
2026-09-30 15:53:08 +00:00
Agus Zubiaga 5becf8b591 editor: Fix panic when showing pending input in a read-only buffer (#64730)
# Objective

Fixes ZED-BTA, ZED-8MC, ZED-875 and ZED-80K. Fixes FR-489.

When you have a binding like `j k`, Zed shows the `j` underlined while
it waits for the next key. We figured out where that `j` went by
assuming it was always inserted. In a read-only buffer it isn't, so with
the cursor at the end of the file we ended up pointing one character
past the end and crashed.

## Solution

We now take anchors at each cursor before inserting and read the
positions back from them afterwards, so we only highlight text that
actually made it into the buffer. This also covers other cases where the
insert gets dropped, like a read-only file inside project search. Also
removed the editor's own read-only check there, since it's no longer
needed.

## Testing

- `test_jk_pending_input_at_end_of_read_only_buffer` covers this and
panics without the fix.
- To reproduce on `main`: bind `"j k": "editor::Cancel"` in the `Editor`
context, put the cursor at the end of a file, run *workspace: toggle
read only file*, and press `j`.

## 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:

- Fixed a crash when typing the start of a multi-key binding at the end
of a read-only file.
2026-09-28 13:24:52 +00:00
Aru Sahni 4f70d91bda editor: Add support for customizable soft wrap indentation (#63468)
# Objective

- Soft wrapped lines currently inherit the indentation of their first
line. This can be challenging for those coming from different editors,
or with different expectations.
- Allow users to customize the soft wrap behavior to wrap with extra
indent, or no indent at all.
- Fixes #18687

## Solution

- Introduce 3 soft-wrap indent configuration values (in addition to the
default of `same`): `none`, `extra_one`, and `extra_two` (where they are
multiples of the indent column width).
- Plumb indent configuration through to the various gpui and editor
components that are concerned with wrapping.
- Update code action icon placement to accommodate `none`-level wrap
indentation (preceded by a refactor of the function used to calculate
its display row).
- Fixed an existing bug in `WrapSnapshot::soft_wrap_indent` where
querying a 0-indent wrap returned `None` instead of `Some(0)`

## Testing

- Added tests to `wrap_map.rs` for all indentation levels.
- Updated the random wrap tests to include indent setting combinations. 
- Added tests for code action icon placement. 
- Validated locally by toggling between the various settings and
observing how the wrap behaved.

## 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

Changes are grouped by commit to ease review.

Screenshots below!

<details>
  <summary>Click to view showcase</summary>

**`same` indent** (current Zed behavior)
<img width="764" height="844" alt="Screenshot from 2026-08-02 22-45-54"
src="https://github.com/user-attachments/assets/83e1465c-0e8e-445d-a172-9e1b446406b7"
/>

**`none` indent**
<img width="764" height="844" alt="Screenshot from 2026-08-02 22-45-39"
src="https://github.com/user-attachments/assets/99b282b6-d308-453d-b08b-e10af824f307"
/>

**`extra_one` indent**
<img width="764" height="844" alt="Screenshot from 2026-08-02 22-46-06"
src="https://github.com/user-attachments/assets/c7480c84-f1a2-485d-b831-b97fe55c0b03"
/>

**`extra_two` indent**
<img width="764" height="844" alt="Screenshot from 2026-08-02 22-46-19"
src="https://github.com/user-attachments/assets/badc4996-e1bf-4237-9add-babf08f13897"
/>

**the setting**
<img width="826" height="336" alt="Screenshot from 2026-08-02 22-42-19"
src="https://github.com/user-attachments/assets/906b4e8e-1366-4a4e-a2cf-4f8bd67fd604"
/>


</details>

---

Release Notes:

- Added a `soft_wrap_indent` setting (`"none"`, `"same"`, `"extra_one"`,
`"extra_two"`) to configure indentation for soft-wrapped continuation
lines.
- Fixed soft-wrap continuation line indentation calculation for
unindented lines starting at column 0.
- [GPUI] Added `IndentAdjustment` enum to `LineWrapper` to control
indentation of soft-wrapped continuation lines.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-09-28 07:16:22 +00:00
Kirill Bulatov f8f0a28508 Fix breadcrumb highlighting outside excerpts (#64738)
For semantic highlights, we fall back to tree-sitter highlights in the
multi buffers, as we limit the semantic tokens with the excerpt size.

Before, the fall back was also limited to the buffer excerpt, which did
not give enough highlights.

<img width="1728" height="421" alt="better_fallback"
src="https://github.com/user-attachments/assets/99517162-2d57-4369-994d-9cba8a9ac463"
/>

Release Notes:

- Fixed breadcrumb highlighting outside excerpts
2026-09-25 13:25:40 +00:00
Gautam Manchandani ec609f84c1 Fix multicursor indentation (#64675)
# Objective

- Fixes #21334.

## Solution

- Preserve indentation during multicursor edits and selected-block
indentation.
---

Release Notes:

- Fixed indentation corruption during multicursor editing and block
indentation.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-24 23:09:12 +00:00
Gautam Manchandani 5402570caa editor: Mute completion detail text (#64684)
# Objective

Fixes #49883.

## Solution

Render completion detail suffixes with the muted text color while
preserving syntax highlights.

## 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
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

| Before | After |
| --- | --- |
| ![Completion details before the
change](https://github.com/user-attachments/assets/d778761a-bff8-4186-ae4c-a0daca6fcbf3)
| ![Completion details after the
change](https://github.com/user-attachments/assets/4a9c05de-8606-4d12-bbb3-7d15e0afc7fe)
|

---

Release Notes:

- Fixed completion details lacking visual distinction from completion
labels.
2026-09-24 14:56:42 +00:00
Alessandro Martone baee1ca6de editor: Inherit whole word match from buffer search (#64137)
# Objective

Make `editor: select next` / `editor: select previous` more powerful and
conform to VSCode behaviour
Partial fix for #15415

## Solution

When `editor: select next`/`editor: select previous`/`editor: select
all` is used from an existing selection, it'll now inherit whole-word
from the buffer search bar, while it's open.

If those commands are used starting from a single caret, continue to
always match whole words, with case sensitivity continuing to be
configurable in that case.

## Testing

Test both manually, as well as with unit tests:

- Updated `editor::editor_tests::test_select_next` with new assertion
for whole-word matching
- Added
`search::buffer_search::tests::test_set_active_pane_item_syncs_select_search_options`
- Added
`search::buffer_search::tests::test_search_option_change_during_selections`
- Added
`search::buffer_search::tests::test_show_syncs_select_search_options`

## 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:

- Improved `editor: select next` and `editor: select previous` to
respect the buffer search whole-word option.

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
2026-09-24 09:52:26 +00:00
HuaGu-Dragon 532532bb80 lsp: Filter out-of-bounds inlay hints (#64659)
# Objective

Fix the filtering of inlay hints around the buffer bounds.

The per-chunk range filter compared anchors, and anchor order includes
the bias.
A parameter hint (`anchor_before`) clamped to the end of the buffer
sorted before the chunk's end anchor and was kept, while a type/other
hint (`anchor_after`) exactly at the end of a file without a trailing
newline compared equal to it and was dropped.

Also remove the redundant `anyhow::Result` and `async` from the
LSP-to-project inlay hint conversion.

## Solution

- Drop LSP inlay hints whose line is past the last buffer row before
converting them.
Positions past a line's end are still clipped to the line end, as the
LSP spec prescribes for `Position.character`.
- Compare offsets instead of anchors in the per-chunk range filter, so
it does not depend on the hint's anchor bias, and treat the range end as
inclusive when it is the end of the buffer.
- Make `lsp_to_project_hint` a pure function over a `BufferSnapshot`.
The resolve path now converts the response against the same snapshot the
request position was produced from.

## Testing

- `test_inlay_hints_at_buffer_bounds`: row overflow for both hint kinds,
column overflow clipping on a non-last row, and a type hint exactly at
the buffer end.
  Fails on `main` on the row overflow and the buffer end cases.
- An out-of-bounds parameter hint added to the collab
`test_inlay_hint_refresh_is_forwarded`.
- Manually verified that rust-analyzer's closing brace hint appears
after the final `}` of a file without a trailing newline.

## 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:

- Fixed inlay hints positioned past the end of the buffer being shown on
its last line, and inlay hints exactly at the end of a file without a
trailing newline being hidden.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-23 19:04:52 +00:00
Kirill Bulatov eb2f43d982 Fix *Map randomized tests (#64527)
Closes https://github.com/zed-industries/zed/issues/64444

Ensures that with `ITERATIONS=200000 OPERATIONS=30`, each of the
following tests pass: `test_random_inlays`, `test_random_folds`,
`test_random_tabs`, `test_random_wraps`, `test_random_display_map`,
`test_random_blocks`, and 12/14 shards of the diff test.

Each comment contains the bug and the fix explanation.

Release Notes:

- N/A
2026-09-23 16:13:31 +00:00
Agus Zubiaga a982949071 editor: Fix crash when a row highlight's anchors are reversed (#64604)
# Objective

Fixes ZED-BJQ (`slice index starts at N but ends at N-1` in
`Editor::highlighted_display_rows_in_range`).

Since #63395, rendering only looks at the row highlights that intersect
the viewport, found with two binary searches over the stored ranges. If
a stored range has `start > end`, the two searches can cross and we
panic.

That happens with merge conflicts where one side is empty (one branch
deleted the block). The conflict parser built every side as
`anchor_after(start)..anchor_before(end)`, so an empty side became a
zero-width range whose start sorts after its end. When you type your
resolution at that spot, the start anchor moves past the new text while
the end stays put, and until the conflict set re-parses the highlight is
inside out. If the viewport lands inside the typed text on that frame,
Zed crashes.

## Solution

We now search for the start index only within the prefix that ends at
the end index, so an inverted range can never produce an inverted slice;
the existing per-highlight filter drops it. The parser also emits empty
sides as `anchor_before..anchor_after`, so they stay ordered and grow
around text typed into them, which also means the typed lines get the
"ours"/"theirs" color immediately instead of after the re-parse.

## Testing

- `test_row_highlights_for_empty_conflict_side_after_edit` parses an
empty-side conflict, stores its highlight plus a hand-built inside-out
range, types into the empty side, and renders every viewport. It panics
without the editor change.
- `test_parse_conflicts_with_empty_sides` checks the parser emits
ordered ranges for empty sides and that typed text lands inside them.
- To reproduce manually on `main`: open a file with a conflict whose
`ours` side is empty, put the cursor at the start of the `=======` line,
paste more lines than fit on screen, then scroll so only the pasted text
is visible before the conflict re-parses (easiest with a nonzero
`git.gutter_debounce`).

## 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:

- Fixed a crash when typing into an empty side of a merge conflict.
2026-09-22 14:25:51 +00:00
Rajin Khan 189839eef5 editor: Keep deleted gutter markers visible at narrow widths (#64469)
Closes #62923

# Objective

Deleted Git gutter markers collapse into a lens and disappear when the
configured gutter width is narrow relative to the buffer line height.

## Solution

- Clamp the deleted marker's corner radii to the marker quad.
- Keep the existing proportional width calculation for default and
custom gutter widths.
- Restore the width helper and its unit test to their behavior on
`main`.

## Testing

- `cargo build -p zed` passes on macOS with Apple's Metal Toolchain
installed.
- `git diff --check` passes.
- Checked before and after at default width, custom width 1, and custom
width 3 with 15 px and 19 px buffer fonts.
- The deleted marker remains full line height in all six patched cases.
The green added-line strip still follows the configured gutter width.

## 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
- [x] Tests cover the new behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

Before/after comparison: see the latest visual verification in the PR
conversation.

## AI assistance

Codex helped trace the paint geometry, prepare the focused patch, and
assemble the visual comparison. I reviewed the diff and the rendered
results before submission.

---

Release Notes:

- Fixed deleted Git gutter markers disappearing at narrow custom widths.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-09-22 13:19:32 +00:00
linyisu b54cc1d0ac editor: Paint block cursor text upon arrival during animation (#64521)
Follow-up to #63195.

# Objective
When `cursor_animation` is enabled, moving a block cursor (e.g. in Vim
mode) leaves the character underneath hidden until the spring animation
fully finishes, after which the letter pops in.
This happens because `CursorLayout::paint` returned early while
animating, skipping `block_text`.

## Solution
Paint `block_text` upon the animated cursor's arrival at the target
cell, rather than waiting for the entire spring settling phase to
complete:
- Check if any animated corner has reached the target bounds
(`bounds.dilate(...)`).
- If the cursor is still in mid-air, return early so we don't draw the
destination letter prematurely.
- Once it touches the target cell, fall through and paint `block_text`
over the cursor polygon.

## 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 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

## Showcase
Left: before, Right: after


https://github.com/user-attachments/assets/7057f40a-64a7-4035-b8e2-7c0b7dc40069

---

Release Notes:
- Fixed an issue where the block cursor hid the character underneath
until cursor animation completed.

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
2026-09-22 03:48:24 +00:00
Kirill Bulatov dc0bbb2b43 Speedup completions test (#64464)
Follow-up to https://github.com/zed-industries/zed/pull/64139 

Fixes CI flacks like
https://github.com/zed-industries/zed/actions/runs/35351932842/job/105623037967?pr=64405#step:15:7107

Halve the test runtime by avoiding the entire `MultiWorkspace` creation
and redraws.

Release Notes:

- N/A
2026-09-21 16:01:29 +00:00
rn23thakur 8a3f841fbd editor: Fix vertical scroll margin calculation (#63944)
# Objective

- Fixes an issue where setting an arbitrarily high `Vertical Scroll
Margin` fails to perfectly lock the cursor in the center of the viewport
(Typewriter Mode?). In certain cases one could go up/down a line before
auto-scroll gets triggered, deviating from user intent.
- Fixes #63862

## Solution

- **The Issue:** When `Vertical Scroll Margin` is very high, the
effective margin applied above and below the cursor is derived from the
viewport's free space:
  ```rust
  ((visible_lines - (target_bottom - target_top)) / 2.0).floor()
  ```
- **The Fix:** Instead of using the same rounded number for both the top
and bottom margins, calculate them separately:
  1. The top margin stays the same as before.
2. The bottom margin is calculated by subtracting the top margin from
the total free screen space.
- This ensures the bottom margin automatically catches whatever fraction
the floor operation on the top margin drops, so the two margins always
sum to the full available space.

## Testing

- Did you test these changes? If so, how?
Ran `cargo test -p editor`, all passed. I've also attached the results
of manual testing in the Showcase section below.

## 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)](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)](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

Before and after screen recording

<details>
<summary>Click to view showcase</summary>

**Before:**


https://private-user-images.githubusercontent.com/63847494/646999418-4dd388b8-4aba-4004-ac4f-6f1e0dad0f70.mp4?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODg5MTE3MTUsIm5iZiI6MTc4ODkxMTQxNSwicGF0aCI6Ii82Mzg0NzQ5NC82NDY5OTk0MTgtNGRkMzg4YjgtNGFiYS00MDA0LWFjNGYtNmYxZTBkYWQwZjcwLm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwOTA4VDIzNTAxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRhZGM5MWExMDkyMDIzZjVlYjcxYmQ4YTRmOTM3MDliNDcyOTUzZjFhYmY1ZTgwMDY0YzhlYmQ1NzllYWYyN2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT12aWRlbyUyRm1wNCJ9.DG6RpiEM-781ZctlvtQeWhw3kAYJ4KS6rNsAmMU38fg

**After:**


https://github.com/user-attachments/assets/4bf870e0-84ba-449a-bf2a-925c4a90d5ed

</details>

Release Notes:

- Fixed the cursor not staying perfectly centered when using a high
Vertical Scroll Margin (Typewriter Mode).

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-09-18 11:24:01 +00:00
Cain 7a01ac15c5 editor: Fix cursor animation across width and scroll changes (#64184)
Follow-up to #63195.

This PR fixes the cursor animation problems reported in [this
comment](https://github.com/zed-industries/zed/pull/63195#issuecomment-5662566417):

- Block cursors snapped instead of animating when moving between
characters with different display widths, such as an ASCII character and
an emoji or CJK character.
- Cursor animation disappeared near the top and bottom scroll margins
when keyboard navigation triggered vertical autoscrolling.

The first issue happened because any cursor geometry size change was
treated as a reason to snap. Cursor movement now retargets the animation
when either the rectangle position or size changes, while geometry
changes without a logical cursor move still snap immediately.

The second issue happened because every viewport change cleared the
active animation. Scroll-only viewport changes now translate the current
and target corner positions, as well as the previous target geometry, by
the scroll pixel delta before retargeting. This preserves the spring's
motion and velocity across autoscroll. Actual layout changes, including
text-area size, line height, and font advance changes, continue to snap.

Regression coverage includes:

- Both narrow-to-wide and wide-to-narrow cursor transitions, including
convergence to the new rectangle.
- Cursor movement in both directions while the viewport scrolls.
- Scrolling during an active animation without clearing its position or
velocity.
- Layout changes that must still snap.
- An editor-level keyboard autoscroll test using a vertical scroll
margin of 3.

Validation:

- `cargo test -p editor cursor_animation --lib`
- `cargo fmt --all --check`
- `cargo build -p zed --bin zed --profile release-fast`
- Manual verification with the release-fast binary

Release Notes:

- Fixed cursor animations when moving between characters of different
widths and during keyboard-triggered autoscrolling.

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
2026-09-16 23:26:23 +00:00
itsfuad 3d91988e46 editor: Fix columnar selection coordinates (#63723)
Closes #63712

## Summary

- Use tab-expanded grapheme columns for Add Selection Above/Below when
`skip_soft_wrap` is enabled, rather than UTF-8 byte offsets or Unicode
scalar counts.
- Keep mouse rectangles pixel-based and preserve logical selection goals
across short rows, direction changes, and selection/text undo and redo.
- Reconcile columnar groups when selections change, while preserving
committed groups during cancellable mouse previews.
- Batch source and destination queries by row and skip fully replaced
input rows without a persistent row cache.
- Handle folds, inlays, and replacement blocks with small map-query
additions, and fix the tab bitmap boundary at a tab size of 128.

## Validation

- Full editor library suite: 1,109 passed, one ignored.
- Editor Clippy and scoped formatting passed.
- Regression checks failed without the corresponding lifecycle and
batching fixes, then passed with them restored.
- The three related sync/history tests were rerun and passed after the
final callback-variable renames.

Release Notes:

- Fixed columnar selections landing in the wrong column around non-ASCII
text, tabs, soft wraps, and collapsed content.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-09-16 16:40:28 +00:00
itsfuad 0dea8c63d9 editor: Render point diagnostics without glyphs (#63933)
Closes #63084.

Zed already normalizes most empty and line-terminator-only diagnostic
ranges onto an adjacent character. A diagnostic can still remain a true
point when its position has no glyph, such as column zero of an empty
line or an empty file. The shaped-text path has no `TextRun` at that
position, so the diagnostic appears in diagnostic UI but has no editor
squiggle.

Render only diagnostics that remain zero-width after ingress as a one-em
wavy underline at their `DisplayPoint`. This keeps the stored LSP range
unchanged, uses the existing diagnostic underline policy and font
metrics, and also paints the decoration in a pinned sticky-header copy
when an anchored point survives an edit.

## Evidence

### Empty Go file with gopls

Before:

<img width="471" height="430" alt="Empty Go file before the fix:
diagnostic message without a squiggle"
src="https://github.com/user-attachments/assets/a7f29dd3-a16c-43ea-a53f-d0264efb4ce0"
/>

After:

<img width="471" height="430" alt="Empty Go file after the fix:
diagnostic message with a point squiggle"
src="https://github.com/user-attachments/assets/0546970a-e24e-4e15-a764-d548291eb623"
/>

`gopls` reports `expected ';', found 'EOF'` at `(0,0)..(0,0)` for the
empty file. The diagnostic message is present in both builds; only the
patched build paints the point squiggle.

Sticky-header behavior was also verified with a deterministic stdio LSP.
Before/after recordings are included in the review response below.

## Validation

- `cargo test -p editor point_diagnostic`
- `cargo test -p editor test_point_diagnostic_stays_in_edited_excerpt`
- `cargo test -p editor
test_point_diagnostics_follow_expanded_deletions`
- `cargo test -p project test_empty_diagnostic_ranges`
- `cargo test -p project test_diagnostic_range_spanning_line_terminator`
- `cargo fmt --all -- --check`
- `CCACHE_TEMPDIR=/tmp/zed-ccache-tmp ./script/clippy -p editor -p gpui
-p multi_buffer -p project`
- `git diff --check`
- Manual before/after verification with gopls on an empty Go file
- Manual before/after verification of a retained point diagnostic in a
sticky header
- Manual Fedora verification of physical overlap handling with
`.ZedMono` and proportional Jomolhari text

Regression coverage also includes retained point diagnostics across
edited excerpt boundaries and expanded deleted diff hunks at the
beginning, middle, and EOF, including an empty live buffer, plus
painted-span severity arbitration for point-vs-range and point-vs-point
overlaps.

Release Notes:

- Fixed missing editor underlines for language server diagnostics at
positions without underlying text.
- [GPUI] N/A

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-09-16 16:04:28 +00:00
Ibrahim Khan c6124d3525 editor: Expand excerpts from deleted diff hunks (#63946)
# Objective

Fixes #62278.

Allow `editor: expand excerpts` from deleted text in unified diffs.

## Solution

- Resolve cursor and selection ranges against the current snapshot,
including deleted hunks.
- Preserve half-open selection boundaries and include trailing empty
excerpts at EOF.
- Skip removed paths during expansion.

## Testing

Regression coverage includes deleted-hunk cursors and selections, stale
paths, selections ending at excerpt boundaries, and trailing empty
excerpts. The boundary and EOF cases cover all three expansion
directions. The Bookmarks action case uses `excerpt_context_lines: 0`.

The new boundary and EOF regressions failed before the fix and passed
afterward.

- `cargo test --locked -p editor -p multi_buffer --lib`: 1026 editor
tests and 67 multibuffer tests passed; 1 ignored.
- `./script/clippy -p editor -p multi_buffer`: passed.
- `cargo fmt --all -- --check`: passed.
- `git diff --check origin/main..HEAD`: passed.

Automated testing ran on Linux. The first full run hit a SQLite table
lock in `persistence::tests::test_save_and_get_serialized_editor`. The
isolated test and full rerun passed.

## Self-Review Checklist:

- [x] I have reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks, if any, have justifying comments
- [x] The content adheres to Zed UI standards
- [x] Tests cover the new behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed excerpt expansion when the selection is on deleted text in
unified diffs

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-16 16:04:24 +00:00
Vitalii Shevtsov 59adbbe8b9 editor: Honor lsp_results_location on cmd-click (#64039)
# Objective

Fixes #62916.

With `"lsp_results_location": "picker"`, `cmd-b` opens the LSP locations
picker but cmd-clicking the same symbol still opens a `Definitions for
…` multibuffer. #61187 fixed this for the go-to-definition *fallback*;
the definition path itself was left behind.

The setting is only consulted by `handle_nav_action` in `lsp_locations`,
which runs when one of the navigation *actions* is dispatched. Cmd-click
never dispatches them: `cmd_click_reveal_task` either navigates the
cached hover links itself, or calls `go_to_definition_of_kind` /
`go_to_type_definition` directly.

## Solution

Both cmd-click paths now dispatch the matching action (`GoToDefinition`,
`GoToTypeDefinition`, …) when `lsp_results_location` is `picker` and the
click is not a split one, so the picker gets its chance; everything else
is untouched:

- with the default `multi_buffer` setting `picker_action` returns `None`
and the old code runs unchanged;
- alt (split) clicks keep their current behavior, since the split
actions have no picker handler;
- URL and file links keep opening directly — the action is only
dispatched when every resolved link is a `HoverLink::Text`.

The dispatch is deferred to after the current editor update via
`cx.spawn_in`: `LspLocationsPicker::open_for_editor` reads the editor,
so dispatching inline panics with `cannot read editor::Editor while it
is already being updated` (this is also why the existing fallback
dispatch happens from a spawn).

## Testing

`cargo test -p lsp_locations` — two new tests, one per cmd-click path: a
cold cmd-click, and a cmd-click on a link already resolved by hovering
with the modifier held (the path users actually hit). Both fail on
`main` with the fix reverted and pass with it.

Also ran `cargo test -p editor --lib hover` (68 passed) and `cargo
clippy -p editor -p lsp_locations --all-targets`.

Not yet verified by hand in a running Zed build — the automated tests
above are what backs this.

## 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:

- Fixed cmd-click on a symbol ignoring the `lsp_results_location`
setting: with `"picker"` it opened a definitions multibuffer instead of
the picker that `cmd-b` opens
([#62916](https://github.com/zed-industries/zed/issues/62916)).

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-16 16:04:13 +00:00
Kirill Bulatov 67ebcd9517 Fix insertion modes for completions without edit ranges (#64139)
Closes https://github.com/zed-industries/zed/issues/64118


https://github.com/user-attachments/assets/f2152411-6011-4d87-8c8e-d83bed0afbbc

`ty` returns completion text without a `textEdit` or a completion-list
default edit range:

```json
{"label":"value2=","insertText":"value2="}
```

The [LSP
specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem)
explicitly states:

> The `insertText` is subject to interpretation by the client side.

For the reported example, `ˇ` marks the cursor:

```py
test(value1, ˇvalue2)
```

Previously, Zed inferred only a range covering the existing `value2`.
Without an insert range, completion acceptance bypassed
`completions.lsp_insert_mode` and replaced that argument with `value2=`,
producing:

```py
test(value1, value2=)
```

The patch also infers an insert range, ending at the cursor rather than
the end of the word.
This lets the existing setting choose between inserting before `value2`
and replacing it.
When a prefix has already been typed, insertion replaces that prefix
while preserving the text after the cursor.

With the unchanged default, `"replace_suffix"`, Zed replaces text after
the cursor only when it is a suffix of the completion’s label.
Here, `value2` is not a suffix of `value2=`, so Zed inserts and
produces:

```py
test(value1, value2=value2)
```

The suffix and subsequence checks now use the raw LSP `label`, not
decorated menu text or `filterText`.
These checks select the edit range; `insertText` still supplies the
inserted text in this example.

Release Notes:

- Fixed insertion modes for completions without edit ranges
2026-09-16 16:03:26 +00:00
Kirill Bulatov dc339e4f43 Share application adapter implementations (reduce LLVM IR bloat again) (#64262)
Move settings-update routing, fallible deserialization recovery,
selection effects, context-menu initialization, picker resize handles,
and ACP client setup into shared implementations. Inline the small
button callback adapters.

`cargo llvm-lines --locked -p settings_ui`:
Before (01c555b435): 1571017 lines, 53634 copies
After: 1177376 lines (-25.1%), 43380 copies (-19.1%)

With compiler wrappers disabled, `cargo clean --target-dir
target/binary-size-split-build` and `cargo build --locked -p zed`:
Before: 135.6s wall, 1569.8s CPU, zed binary 1175563800 bytes 
After: 140.9s wall (+3.9%), 1588.8s CPU (+1.2%), zed binary 1157304600
bytes (-1.6%, -18.3MB)

Release Notes:

- N/A
2026-09-16 16:03:09 +00:00
Gautam Manchandani a2651e3b56 editor: Fix gutter tooltip modifier hint (#64124)
# Objective

Fixes #58821. Follow-up to #58880: keep the modifier-click hint accurate
when the tooltip switches from breakpoint to bookmark.

## Solution

Build the hint from the configured secondary gutter action instead of
the currently active action.

## 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
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase



https://github.com/user-attachments/assets/c514d30e-9747-40a1-b359-54bc10086366

---

Release Notes:

- Fixed the gutter tooltip's modifier-click hint after holding Command.
2026-09-12 17:16:02 +00:00
Giorgio Pogliani f0261834eb editor: Allow customizing CodeLens text color (#64084)
CodeLens text currently hardcodes `text.muted`, so changing its color
also changes unrelated muted UI text such as the sidebar.

This adds a dedicated `editor.code_lens.foreground` theme color. When
omitted, it falls back to `text.muted`, preserving the existing
appearance of themes while allowing CodeLens text to be customized
independently.

Release Notes:

- Added `editor.code_lens.foreground` for customizing CodeLens text
independently.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-09-11 15:19:53 +00:00
Udeshya 595d62863e Add action parameter comment_empty_lines for editor::ToggleComments (#63961)
# Objective

- Fixes: https://github.com/zed-industries/zed/issues/60738
- Re-iteration of https://github.com/zed-industries/zed/pull/63918 with
suggested changes

## Solution

- Added the parameter `comment_empty_lines` to `editor::ToggleComments`
set to `false` by default.

## Testing

- Tested manually. See showcase below.
- Added two automated tests for the added feature.
- Tested on MacOS.

## 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

## References
The action's behavior was observed across Emacs, VSCode, and Intellij,
and the corresponding keymaps were set accordingly.


https://github.com/user-attachments/assets/36c1a27a-357c-468a-b56b-59ef31265329

https://github.com/user-attachments/assets/de755753-9de1-4771-980f-177810fb85ef

https://github.com/user-attachments/assets/c8ecd261-2bba-4345-89f4-c1d708d8b6d2

## Showcase

Below is the screen recording of these three tests:

1. Behavior of toggling comments when `comment_empty_lines` is `true`.
2. Switching the parameter value to true after commenting a block and
un-commenting the same block does not re-comment the block due to an
empty line in between.
3. Menu bar item is still present, albeit it's behavior is mapped to the
default value of the parameters of the bound action, instead of what is
inside the keybindings file. This (bug?) was present even before. See
the attached clip below.

1.
https://github.com/user-attachments/assets/a9cd2a2c-437b-41a3-bd8e-c4c3a1f350cd
2.
https://github.com/user-attachments/assets/4bbfb77c-9019-410e-9d0a-952d4438d2a7
3.
https://github.com/user-attachments/assets/ca300e2d-2106-4bb7-865b-5d2ab89cd0f2


https://github.com/user-attachments/assets/ec1e47b6-ff99-461e-93af-af925be4d914

---

Release Notes:

- Added `comment_empty_lines` parameter to `editor::ToggleComments` for
multiline selections.
Use `["editor::ToggleComments", {"comment_empty_lines": true}]` to
comment blank lines too (default for Zed keymap now), or
`["editor::ToggleComments", {"comment_empty_lines": false}]` to skip
them (default for VSCode keymap).

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-10 13:39:44 +00:00
Shuhei Kadowaki 284c72404a lsp: Handle dynamic registration of textDocument/documentHighlight (#63029)
Zed did not advertise document highlight dynamic registration support or
handle `textDocument/documentHighlight` registrations. Dynamically
registered providers therefore fell through to the unhandled-capability
path, while servers with a fallback had to advertise a static provider
for every attached document.

Advertise dynamic registration support and track document highlight
registrations and unregistrations alongside the other selector-aware
dynamic text document capabilities. Refresh editors whenever the
effective document highlight registration state changes, including
selector-only changes that leave the merged provider unchanged, so
runtime registrations take effect immediately and unregistrations clear
stale or in-flight highlights.

Add coverage for the client capability, registration lifecycle with
multiple selectors sharing identical provider options, and editor
refresh behavior when an applicable selector is added or removed.

## 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: GPT-5.6 Sol <noreply@openai.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-09 14:55:56 +00:00
Kirill Bulatov 002161d5ba Support commands in inlay hints (#63605)
Closes https://github.com/zed-industries/zed/discussions/51582

During testing, spotted that if I toggle off the hints with the modifier
keys, they are resurrected on scrolling — fixed that in a small commit
on top.

Release Notes:

- Supported commands in inlay hints
2026-09-09 13:47:39 +00:00
Kirill Bulatov 0690433b60 Support LSP command executions and showDocument requests (#63607)
Closes https://github.com/zed-industries/zed/issues/13756
Closes https://github.com/zed-industries/zed/issues/61572

Last window client capability we were missing!
<img width="1557" height="159" alt="image"
src="https://github.com/user-attachments/assets/2cca5d92-a28e-4262-8f55-89f582782bbc"
/>

Two features are connected to each other, as most of the commands result
in opening a document:


https://github.com/user-attachments/assets/661aae88-7af9-4173-9f6a-2fd11dbec675


Release Notes:

- Added support for LSP command executions and showDocument requests
2026-09-09 13:47:28 +00:00
Rani 4612aa2feb editor: Skip multi-cursor selection broadcast when unshared (#60605)
Resubmit of #59731, which got auto-closed when I accidentally deleted
its branch. It wasn't rejected, it had already been reviewed. This is
rebased onto latest `main`, and osiewicz's review feedback (using `_`
for the unused param in the trait default) is already in.

Follow-up to #58510. Profiling multi-cursor typing on current main
showed the per-keystroke `set_active_selections` broadcast does an
O(selections) multi-buffer anchor remap and runs even with zero
collaborators (about 0.9ms/call at 1k cursors, 8.4ms at 10k, fired ~3x
per edited iteration).

This skips the broadcast when the buffer has no audience, and
re-publishes on share so there's no regression:

- Add `CollaborationHub::should_broadcast_selections`, defaulting to
`true`. `Entity<Project>` overrides it to `Project::is_shared()`, which
is true for a host that shared the project and for a collab guest, and
stays correct before peer-join notifications have propagated locally
(unlike a live collaborator count). A purely local project has no
audience.
- Gate `set_active_selections` in `selections_did_change` on it.
Follow-mode is unaffected since it uses the separate
UpdateFollowers/UpdateView channel, and the focused user's own cursors
render from `editor.selections`, not `remote_selections`.
- When the project becomes (re)shared (`RemoteIdChanged(Some)`,
`Reshared`, `HostReshared`), the focused editor re-publishes its current
selections, so a peer joining after a share still sees the host's cursor
without waiting for the next selection change.
- Reuse the post-edit display snapshot in the `hard_wrap` branch instead
of taking a redundant fresh buffer snapshot.

Multi-cursor type+delete benchmark: about 5% faster at both 1k and 10k
cursors (615 to 583 ms at 10k, significant). All 773 editor tests pass
locally. Collab and channel-buffer integration tests need the test DB,
so they run on CI.

Discussion and profiling:
https://github.com/zed-industries/zed/issues/32051

Release Notes:

- Improved multi cursor editing performance
2026-09-09 08:20:26 +00:00
Tim Vermeulen ff6a6abbd1 Fix crash in Editor::rotate_selections using cursors on nonconsecutive lines (#63937)
Crash repro:

```
A
1234567890
B
C
```
1. place cursors before `A`, `B`, and `C`
2. run `editor: rotate selections forward`

Caused by the current `Editor::rotate_selections` logic assuming that
the text between the end of one of the lines being rotated and the start
of the next one is just the newline:
```rs
let newline_len = line_ranges[1].start.0 - line_ranges[0].end.0;
```
which fails when those lines aren't consecutive in the editor.

## 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:

- Fixed crash in `editor: rotate selections forward` and `editor: rotate
selections backward` using cursors on nonconsecutive lines.
2026-09-08 20:13:56 +00:00
Kirill Bulatov 20d3cd1d79 Fix block-comment prefix stripping when joining lines (#63916)
Closes
https://github.com/zed-industries/zed/issues/63273#issuecomment-5580302020



https://github.com/user-attachments/assets/0945d43d-9a19-4af6-bc85-c3369d8babb3


Release Notes:

- Fixed block-comment prefix stripping when joining lines
2026-09-08 15:16:55 +00:00
Ali 91c57e8147 editor: Preserve the trailing newline when converting case (#63463)
# Objective
Case conversion commands deleted the newline at the end of the
selection,
merging the selected line into the line below it.

To reproduce:

1. A buffer with two lines:

   ```
   hello world
   goodbye
   ```

2. Put the cursor on line 1 and run `editor: select line` — this selects
   `hello world\n`, newline included.
3. Run `editor: convert to upper camel case`.

Before: `HelloWorldgoodbye`, one line. After: `HelloWorld` / `goodbye`.

## Testing

Added a regression test to `test_manipulate_text`.


Release Notes:
- Fixed the case conversion commands deleting the line break when the
selection
  ended at the start of the next line.
2026-09-04 08:25:51 +00:00
Cain 2988a59241 editor: Add optional cursor movement animation (#63195)
# Objective

Add an optional smooth cursor movement animation to make cursor position
changes easier to follow, especially during larger jumps and
multi-cursor editing.

Related to #4991.

## Solution

- Add a new `cursor_animation.enabled` editor setting, disabled by
default.
- Animate local bar and block cursors using a damped spring while
preserving momentum during rapid cursor movement.
- Support multiple local cursors independently.
- Continue using the cursor color provided by the active theme.
- Snap immediately when scrolling, resizing, or other viewport changes
would make interpolation misleading.
- Respect the `reduce_motion` setting.
- Request animation frames only while an enabled cursor animation is
active.

Enabling the feature causes additional editor redraws while the cursor
is moving, so it is opt-in and the performance cost is mentioned in the
setting documentation.

### Attribution

The cursor spring physics and four-corner deformation algorithm are
adapted from
[vscode-neovide-cursor](https://github.com/LengineerC/vscode-neovide-cursor),
which is available under the MIT License and inspired by Neovide.

The implementation adapts the algorithm to Zed's editor and GPUI
architecture, including viewport handling, selection state
reconciliation, multi-cursor support, theme integration, and
reduced-motion behavior. The attribution and license information are
also retained in the source file.

## Testing

Automated checks run on Windows:

- `cargo fmt --all --check`
- `cargo test -p editor cursor_animation --lib`
  - 15 cursor animation tests passed.

The tests cover:

- Spring convergence.
- Short and long cursor movements.
- Mid-animation retargeting and momentum preservation.
- Multiple independent cursors.
- Selection replacement and state cleanup.
- Viewport and scroll changes.
- Invalid or unusually large timing values.
- Supported cursor shapes.

To test manually:

1. Add the following to the settings file:

   ```json
   "cursor_animation": {
     "enabled": true
   }
   ```

2. Move the cursor using typing, arrow keys, mouse clicks, and
multi-cursor actions.
3. Toggle the setting off and confirm that cursor rendering immediately
returns to its normal behavior.

Manual testing was performed on Windows and Linux using a release build
from this exact PR branch.

Verified that:

- Cursor animation is disabled by default.
- Enabling `cursor_animation.enabled` is hot-reloaded without restarting
Zed.
- Disabling the setting immediately restores the original cursor
behavior.
- Cursor movement remains responsive during typing, keyboard navigation,
and mouse navigation.

This exact PR branch has not yet been manually tested on macOS.

## 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


https://github.com/user-attachments/assets/17450529-491e-4982-b539-c46e3d5df467

---

Release Notes:

- Added an optional cursor movement animation setting.

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
2026-09-04 07:36:22 +00:00
Som d9141a3fa6 editor: Keep deleted git-gutter marker visible at small custom widths (#63434)
# Objective

- Fixes #62923.
- When `gutter.git_gutter_width` is set to a small `Custom` value (e.g.
`{"custom": 6.0}`), the deleted-line marker becomes disproportionately
small. It is nearly invisible in the reporter's screenshots, while
added/modified markers scale acceptably.

## Solution

- The deleted marker's `Default` arm uses a `0.35 * line_height` base;
the strip's `Default` arm uses `0.275 * line_height`. That 27% larger
base is what keeps the pill-shaped deleted marker visible next to the
rectangular added/modified strips.
- The `Custom(N)` arm previously used `N` for both branches, dropping
the boost. This PR routes the deleted-empty case through a new
`deleted_marker_base_width(setting, line_height)` helper that applies a
single `DELETED_MARKER_WIDTH_RATIO = 0.35 / 0.275` constant to both
arms.
- Default-mode pixels are byte-identical because `floor(0.275 * lh *
0.35/0.275)` reduces to `floor(0.35 * lh)`. Custom-mode gains the same
1.273× multiplier the default has always had.

## Testing

- Added a pure `#[test] fn test_deleted_marker_base_width` covering
three invariants:
- `Default` at `line_height = 22.0` returns `7px`, identical to the
previous default arm.
- `Custom(6.0)` at `line_height = 22.0` returns a width greater than 6.0
(visibility preserved).
- `Custom(0.0)` returns `0.0`, so the width-0 render path is unchanged.
- Verified locally on Windows: `cargo fmt --all -- --check`, `cargo
check -p editor`, and `cargo clippy -p editor --all-targets -- -D
warnings` all exit 0.
- I have not visually verified the rendered marker on macOS or Linux. A
reviewer with the reporter's setup (`git_gutter_width: {"custom": 6.0}`
on macOS) can confirm the pill stays visible.

## 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:

- Fixed the deleted git-gutter marker becoming nearly invisible when
`git_gutter_width` is set to a small custom pixel value.
2026-09-04 07:35:34 +00:00
Shuhei Kadowaki 23aca9895c lsp: Honor dynamic LSP document selectors (#59243)
Zed previously discarded the documentSelector from dynamically
registered textDocument capabilities and treated those capabilities as
applicable to every buffer attached to the server. This could route
requests for documents outside a registration selector.

Track dynamic textDocument registrations by method and registration ID,
and use their selectors when routing local requests, checking
capabilities, and deriving completion triggers. Static capabilities
continue to apply to every attached buffer. Language and URI scheme
matching are supported, while unsupported pattern matching remains
fail-open.

Keep document color, symbol, link, code lens, and folding range caches
aligned with the selector-aware server set so incapable or non-matching
servers do not leave caches perpetually incomplete.

Require an advertised diagnostic provider before sending pull diagnostic
requests, and add integration coverage for selector-aware dynamic
completion registration and trigger updates.

---

Release Notes:

- Improved language server request routing to respect dynamically
registered document selectors.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-02 19:54:04 +00:00
Kaj Kowalski f8000a30f9 Properly clear diagnostics data for stopped servers (#63460)
# Objective

Diagnostics published by a language server survive the buffer being
detached from that server, so a file keeps showing errors from a server
that is no longer reading it.

To reproduce:

1. Install the [GitHub Actions
extension](https://zed.dev/extensions/github-actions).
2. Open a composite action definition,
`.github/actions/<name>/action.yml`.
3. Select the GitHub Actions language for it in the language selector.
That server validates the file as a workflow, so it reports `on` and
`jobs` as missing and `inputs`, `outputs` and `runs` as unexpected.
4. Select YAML again, since GitHub Actions was not what you wanted here.
5. The errors are still there. `editor: restart language servers` does
not clear them either. They go away only once the buffer is dropped, in
practice by switching to another project and back.

Two things keep them alive:

- `LocalLspStore::unregister_buffer_from_language_servers` drops the
snapshot bookkeeping and sends `didClose`, but never clears what that
server already published. `LspStore::set_language_for_buffer` calls it,
so a language change detaches the buffer while leaving the old verdict
on it.
- Restarting does not reach the server either.
`stop_local_language_servers_for_buffers` collects servers through
`language_server_ids_for_buffer`, evaluated against the language the
buffer has *now*. The old server no longer matches, so it is never
stopped, and it is typically still running legitimately for other files
in the project. Only `stop_local_language_server` clears diagnostics,
and it is never reached for that server.

## Solution

The first commit cleared the detached server's diagnostics inside
`unregister_buffer_from_language_servers`, on `didClose`. Review pointed
out that publishes are applied by path regardless of registration, so a
running server can legitimately describe a file that is no longer open
in it, and that this clearing also left `diagnostic_summaries` and the
worktree's per-path diagnostics stale.

The second commit reworks this. Detaching a buffer now only drops the
buffer's entry in `buffers_opened_in_servers` and the path's
pull-diagnostics result ids for the servers it left, two pieces of
per-server state that previously leaked. After the buffer is registered
with the servers of its new language, the server tree is rebuilt through
`refresh_server_tree`, the same pruning that runs on settings changes:
every server no registered buffer maps to any more is stopped through
`stop_local_language_server`, whose path already clears buffer
diagnostic sets, `diagnostic_summaries` and worktree diagnostics. A
detached server that other buffers still map to keeps running and keeps
everything it published. An earlier revision judged orphanhood by
`buffers_opened_in_servers`, which is only filled in once a server runs,
so it stopped servers that were still starting;
`test_context_completion_provider_mentions` caught that.

## Testing

Added `test_selecting_a_language_clears_the_old_servers_diagnostics`: a
Rust buffer gets a diagnostic from a fake server, the buffer is switched
to JavaScript, and afterwards both the buffer's diagnostics and the
project-level `diagnostic_summary` must be empty. It fails on `main`,
where the message survives the switch:

```text
< ["unused constant"]
> []
```

The test passes with the rework and fails without it. The `project` test
suite, `script/clippy` and style checks ran green on the reworked change
in CI. Tested on Linux; the change is platform independent.

## 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

The buffer is back on YAML, as the status bar shows, while the workflow
schema's complaints from the GitHub Actions server are still on screen:
`on` and `jobs` reported missing, and `inputs`, `outputs` and `runs`
reported as unexpected values.

<img width="2514" height="2008" alt="Screenshot From 2026-08-30
21-52-12"
src="https://github.com/user-attachments/assets/040898a6-cc61-41b6-88c6-f346666e8e13"
/>

---

Release Notes:

- Fixed diagnostics from the previous language server staying on a file
after changing its language.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-02 18:23:56 +00:00
Kirill Bulatov 769d0befa7 Support Emmet's wrap with abbreviation (#63383)
Closes https://github.com/zed-industries/zed/issues/15588


https://github.com/user-attachments/assets/2813d235-6dac-4fe6-9ae0-2783e16270ac

Release Notes:

- Added Emmet's wrap with abbreviation support
2026-09-02 18:21:02 +00:00
itsfuad a24cafa942 editor: Fix completion menu label overlapping documentation text (#63581)
Closes #63301

The completion label row set `min_w_0()`, which removes a flex item's
automatic minimum size and lets it shrink below its own content width.
The label inside is `flex_none` and never shrinks, so for long
completion labels the text overflowed the row and, with GPUI's default
`Overflow::Visible`, painted directly on top of the right-aligned
documentation text.

Removing `min_w_0()` restores the row's automatic minimum so it no
longer shrinks past the label. The documentation label already has
`flex_shrink(1.0)`, `min_w_0()` and `truncate()`, so it is now the only
element that gives way, shrinking and ellipsizing as intended.

The resulting layout is `[full label] [documentation, ellipsized when it
overflows]`.

### Before

<img width="687" height="426" alt="Screenshot From 2026-09-02 00-48-03"
src="https://github.com/user-attachments/assets/b734b632-fd05-4afc-8b02-b231922646ef"
/>


### After

<img width="853" height="526" alt="Screenshot From 2026-09-02 02-23-41"
src="https://github.com/user-attachments/assets/60281115-5a8d-4f4e-bfe0-c037ff7244e3"
/>


Release Notes:

- Fixed completion menu labels overlapping the documentation text for
long completion items
2026-09-02 13:11:30 +00:00
Ben Kunkle 229450844d git: Move diff hunk operations onto buffer diffs (#63556)
# Objective

Keep Git-specific diff-base knowledge in `GitStore`, where Git
operations are defined.

Related to FR-135.

## Solution

Give each `BufferDiff` its supported hunk operations. Keep editor hooks
limited to rendering custom controls.

## 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
2026-09-01 15:52:33 +00:00
Conrad Irwin 3f00b5d75d editor: Limit row highlight expansion to viewport (#63395)
## Summary

- Limit row-highlight expansion during editor rendering to ranges that
intersect the visible viewport.
- Use the stable multibuffer anchor ordering established by #62636 to
binary-prune every highlight group, including ranges with diff-base
anchors.
- Preserve exact-boundary highlights for custom blocks and add
regression coverage comparing viewport results with the full-editor
result.

This is stacked on #63394 so the benchmark fixture and batched conflict
anchor conversion are available independently.

## Performance

The severe synthetic workload contains 128 conflicted files, 256
conflict regions per file, and 163,840 accumulated row-highlight ranges.

In the initial paired measurement, viewport filtering reduced:

- project-diff refresh from 67.6–87.8 seconds to 13.47–13.53 seconds;
- cumulative row-highlight expansion from 53–74 seconds to about 7.7
milliseconds;
- the longest individual expansion from 817–875 milliseconds to
0.063–0.071 milliseconds;
- examined highlight ranges from 10.7–15.6 million to about 2,500.

After isolating this commit from the separate block-insertion experiment
and hardening the anchor-boundary behavior, two severe-workload runs
completed in 17.75 and 20.51 seconds. Those isolated runs are not a
direct A/B comparison with the initial numbers because they
intentionally omit the block-insertion fast path.

## Validation

- `cargo test -p editor test_highlighted_display_rows_in_range`
- `./script/clippy -p editor`
- `git diff --check`
- Two independent code reviews focused on viewport boundaries and anchor
ordering

Release Notes:

- Improved project diff performance for repositories with many merge
conflicts.
2026-08-31 16:38:42 +00:00
Kirill Bulatov adc72a5a49 Support CSV preview in project-less set-ups (#63350)
Closes https://github.com/zed-industries/zed/issues/63265

Release Notes:

- Fixed CSV preview not showing in project-less set-ups
2026-08-31 12:04:06 +00:00
Kirill Bulatov 24254879b7 Stop re-resolving editorconfig sections on every language settings lookup (#63323)
Closes https://github.com/zed-industries/zed/issues/59689

Symbolicating the reporter's profile (21s of typing, Windows) showed
`Window::draw` taking 63% of the main thread at ~62 redraws/s (p95 draw
= 40ms), and 30.9% of the *entire* main thread inside
`EditorconfigStore::properties()`:
every `LanguageSettings` lookup — several per frame via
`DisplayMap::tab_size`, `MultiBuffer::language_settings`, indent guides,
and `LspStore::supports_range_formatting` — re-ran the full editorconfig
resolution (ancestor walk plus `ec4rs::Section::apply_to` over every key
of every section) and then cloned the whole `LanguageSettings` struct.
Real-world `.editorconfig` files carry hundreds of irrelevant keys
(`dotnet_*`, `ij_*`, ...), so the per-call map assembly dominated:
`RtlAllocateHeap` 7.3%, `memcmp` 7.0%, `memcpy` 6.6%,
`Properties::find_idx` 5.9% self time.

## Commit 1: resolve only the editorconfig properties Zed reads

- `EditorconfigStore::properties()` now applies only the 7 keys Zed
consumes (`indent_style`, `indent_size`, `tab_width`, `end_of_line`,
`max_line_length`, `insert_final_newline`, `trim_trailing_whitespace`)
instead of materializing every key of every matching section.
- Worktrees with no editorconfig at all now return `None` early instead
of allocating an empty `Properties` and forcing a `LanguageSettings`
clone on every lookup.
- Adds an `editor_render_with_editorconfig` benchmark: maximized window,
file-backed buffer at `src/app/components/editor_pane.ts`, a root
`.editorconfig` shaped after [the second
report](https://github.com/zed-industries/zed/issues/59689#issuecomment-5475124891)
(no `root = true`, a `[*]` section with ~3200 keys, 25 sections with
large `{...}` alternation lists) plus a 4-level nested chain, and a
typing workload (insert/delete + cursor moves).

```
main (770aac345c):      time: [37.905 ms 38.005 ms 38.107 ms]
                        time: [38.069 ms 38.157 ms 38.248 ms]
this commit:            time: [2.8547 ms 2.8618 ms 2.8702 ms]
                        time: [2.8372 ms 2.8435 ms 2.8510 ms]
```

The candidate is ~13x faster.
GPUI frame report over the same workload: window draw p50 12.71 ms →
0.76 ms, p99 23.38 ms → 1.22 ms; frame budget overruns 556 → 0.

## Commit 2: cache resolved `LanguageSettings` per buffer

- `Buffer` and `BufferSnapshot` now hold `resolved_settings:
Arc<LanguageSettings>`, recomputed by a `SettingsStore` global observer.
- Global methods for retrieving the settings are still there, but buffer
only uses them for multi buffer's `language_settings_at` with an
injected language different from the buffer's primary; cold scopes such
as extension API, LSP workspace configuration, server startup still use
the global resolution

Same benchmark, same method, on top of commit 1 (alternated runs, quiet
machine):

```
commit 1:               time: [2.8547 ms 2.8618 ms 2.8702 ms]
                        time: [2.8372 ms 2.8435 ms 2.8510 ms]
this commit:            time: [1.6256 ms 1.6325 ms 1.6403 ms]
                        change: [-42.685% -42.270% -41.854%] (p = 0.00 < 0.05)
                        time: [1.6221 ms 1.6284 ms 1.6352 ms]
```

Window draw p50 0.76 ms → 0.47 ms, p99 1.22 ms → 0.69 ms, max 1.02 ms;
zero frame-budget overruns on both sides.
Combined, the benchmark's per-keystroke cost drops ~23x vs `main`
(37.9–38.2 ms → 1.62–1.64 ms).


Release Notes:

- Improved typing and rendering performance in projects that use
`.editorconfig` files.
2026-08-31 11:58:50 +00:00
Kirill Bulatov ded896cc91 Keep first match selecting during type on search (#63375)
Follow-up to https://github.com/zed-industries/zed/pull/62506

Before:


https://github.com/user-attachments/assets/19f6f0df-c5e3-417e-a351-13a09ccb726b

After:


https://github.com/user-attachments/assets/0b302ed7-a98d-4db4-81bc-d67f5cc7db87


* Fixes type on search not selecting the very first result as the
regular search does.
* Unifies the flicker freezing state better in the editor

Release Notes:

- N/A
2026-08-31 11:41:34 +00:00
Kirill Bulatov 399258feea Reduce LLVM IR bloat in closure funnels (#63426)
Follow-up to https://github.com/zed-industries/zed/pull/63232

Cuts closure monomorphization in settings and editor: settings file
updates now share one boxed write-pipeline instantiation instead of
inlining the `SettingsContent` clone, both `serde_json::to_value` calls,
and the JSON diff at every call site; `Editor::register_action` and the
settings enum dropdown get the same treatment. Behavior and public
signatures are unchanged; thin generic shims remain.

Symbol table of the release binary:
Before: `update_settings_file_inner` 229 instantiations, inlined
`serde_json` `SerializeMap` machinery 6547 copies
After: 3 instantiations, 673 copies (-89.7%); `render_dropdown` is no
longer instantiated at all

With sccache disabled, `cargo clean` and `cargo build --release -p zed`:
Before: zed binary 420677880 bytes
After: zed binary 396999464 bytes (-5.6%, -23.7MB)

Release Notes:

- N/A
2026-08-29 22:51:20 +00:00
Cole Miller a61e2609c1 Normalize ranges returned by language servers in more cases (#63372)
Previously, we'd panic when constructing multibuffer excerpts in
response to "find all references" if a language server returned a
reversed range. This PR makes it so we normalize those ranges using the
existing `range_from_lsp` helper before passing them to
`set_excerpts_for_path`. It also replaces several other places where we
were calling `point_from_lsp` on each endpoint of a range separately
with `range_from_lsp`.

Closes ZED-79W

Co-authored-by: Mikayla <mikayla@zed.dev>

Release Notes:
- Fixed a crash with some languages servers when handling
`editor::FindAllReferences`.
2026-08-28 18:06:41 +00:00