Commit graph

3516 commits

Author SHA1 Message Date
Kirill Bulatov
42571e405f
Ensure inlay hint toggling with modifiers happens fast (#25852)
Follow-up of https://github.com/zed-industries/zed/pull/25766 
Fixes the bugs found:

* modifier toggle not happening instantly due to `edit_debounce_ms`
considered
* hint update race that ignored the cache clear

Release Notes:

- N/A
2025-03-01 08:15:57 +00:00
João Marcos
2d61a51ded
Diff View: Scroll to center of hunks when reviewing (#25846)
When reviewing hunks, scroll to put them at the center of the screen
so you can better see the context around that hunk.

The field `center_cursor` was added to the actions `editor::GoToHunk`
and `editor::GoToPrevHunk`, this was set to `false` by default in
keymaps, as it wouldn't help with in-editor navigation.

The field is set to `true` for when you trigger `git::StageAndNext`
and `git::UnstageAndNext`, this is also `true` for the buttons in the
Diff View toolbar.

Release Notes:

- N/A
2025-03-01 03:20:26 +00:00
João Marcos
a2876f5d3e
Support hunk-wise StageAndNext and UnstageAndNext (#25845)
This PR adds the `whole_excerpt` field to the actions:

- `git::StageAndNext`
- `git::UnstageAndNext`

Which is set by false by default, effectively, now staging and unstaging
with these actions is done hunk-by-hunk, this also affects the `Stage`
and
`Unstage` buttons in the Diff View toolbar.

A caveat: with this PR, there is no way to configure the buttons in the
Diff
View toolbar to restore the previous behavior, if we want, I think we
can make
it a setting, but let's see if anyone really wants that.

Release Notes:

- N/A
2025-03-01 02:39:08 +00:00
Max Brunsfeld
1c4c568068
Allow unfolding deleted buffers in project diff w/ keyboard (#25835)
Release Notes:

- N/A
2025-02-28 16:02:35 -08:00
Max Brunsfeld
0c2bbb3aa9
Optimistically update hunk states when staging and unstaging hunks (#25687)
This PR adds an optimistic update when staging or unstaging diff hunks.
In the process, I've also refactored the logic for staging and unstaging
hunks, to consolidate more of it in the `buffer_diff` crate.

I've also changed the way that we treat untracked files. Previously, we
maintained an empty diff for them, so as not to show unwanted
entire-file diff hunks in a regular editor. But then in the project diff
view, we had to account for this, and replace these empty diffs with
entire-file diffs. This form of state management made it more difficult
to store the pending hunks, so now we always use the same
`BufferDiff`/`BufferDiffSnapshot` for untracked files (with a single
hunk spanning the entire buffer), but we just have a special case in
regular buffers, that avoids showing that entire-file hunk.

* [x] Avoid creating a long queue of `set_index` operations when
staging/unstaging rapidly
* [x] Keep pending hunks when diff is recalculated without base text
changes
* [x] Be optimistic even when staging the single hunk in added/deleted
files
* Testing

Release Notes:

- N/A

---------

Co-authored-by: Cole Miller <m@cole-miller.net>
2025-02-28 20:55:29 +00:00
Nate Butler
8a22a07d14
git: Adjust rendering of git hunks (#25824)
- Light themes get their own values (creating better contrast and a
better distinction between staged and unstaged hunks in light themes.)
- Scrollbar git hunks indicators now use the correct colors

Before:

![CleanShot 2025-02-28 at 14 31
29@2x](https://github.com/user-attachments/assets/038fe11c-7163-4f1b-92b8-56b24c8e9443)

After:

![CleanShot 2025-02-28 at 14 32
04@2x](https://github.com/user-attachments/assets/869d33d9-d925-4cbe-84bd-e54caf971431)


Release Notes:

- Fixed an issue where git hunk indicators in editor scrollbars used the
incorrect colors.
2025-02-28 19:54:12 +00:00
smit
fad4df5e70
editor: Add Organize Imports Action (#25793)
Closes #10004

This PR adds support for the organize imports action. Previously, you
had to manually configure it in the settings and then use format to run
it.

Note: Default key binding will be `alt-shift-o` which is similar to
VSCode's organize import. Also, because `cmd-shift-o` is taken by
outline picker.

Todo:

- [x] Initial working
- [x] Handle remote
- [x] Handle multi buffer
- [x] Can we make it generic for executing any code action?

Release Notes:

- Added `editor:OrganizeImports` action to organize imports (sort,
remove unused, etc) for supported LSPs. You can trigger it by using the
`alt-shift-o` key binding.
2025-03-01 00:59:09 +05:30
Piotr Osiewicz
e4e758db3a
Rust 1.85 (#25272)
Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-02-28 18:33:35 +01:00
Kirill Bulatov
7440833ff1
Add a way to toggle inlay hints with modifiers #2 (#25766)
https://github.com/zed-industries/zed/pull/25752 with fixes on top

* Ensures no flickering happens for all modifiers `: false` case
* Dismisses the toggled state on focus out
* Reworks cache state so that "enabled" and "toggled by modifiers" are
different states with their own lifecycle

Release Notes:

- N/A
2025-02-28 08:03:25 +00:00
Agus Zubiaga
6eb2ffe77a
Support absolute disabled_globs (#25755)
Closes: #25556

We were always comparing `disabled_globs` against the relative file
path, we'll now use the absolute path if the glob is also absolute.

Release Notes:

- Support absolute globs in `edit_predictions.disabled_globs`
2025-02-27 15:29:32 -03:00
Mikayla Maki
c5632f8c31
Revert "Add a way to toggle inlay hints with modifiers" (#25764)
This PR caused inlay hints to show on every modifiers press

Reverts zed-industries/zed#25752

Release Notes:

- N/A
2025-02-27 10:11:36 -08:00
Cole Miller
4e60ebab5e
Fix toggling deletion hunk with mouse at start of buffer (#25726)
Closes #ISSUE

Release Notes:

- N/A
2025-02-27 12:08:20 -05:00
Kirill Bulatov
e8ef36edcc
Add a way to toggle inlay hints with modifiers (#25752) 2025-02-27 17:53:10 +02:00
João Marcos
be1ac78e11
Unfold buffers in multibuffers when editing them (#25677)
Release Notes:

- Multibuffers: Unfold excerpts when editing their contents.

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2025-02-26 17:39:33 -03:00
Kirill Bulatov
b5a1ae6526
Improve Zed tasks' ZED_WORKTREE_ROOT fallbacks (#25605)
Closes https://github.com/zed-industries/zed/issues/22912

Reworks the task context infrastructure so that it's possible to have
multiple contexts at the same time, and stores all possible worktree
context there.
Task UI code is now falling back to the "active" worktree context, if
active item's context did not produce a resolved task.

Current code does not produce meaningful results for projects with
multiple worktrees to avoid ambiguity and design changes: instead of
resolving tasks per worktree context available, extra worktree context
is only used when resolving tasks from the same worktree.

Release Notes:

- Improved Zed tasks' `ZED_WORKTREE_ROOT` fallbacks
2025-02-26 22:30:31 +02:00
Kirill Bulatov
d2b49de0e4
Dismiss active diagnostics on invalidation (#25646)
When migrating to gpui2,
588976d27a (diff-a3da3181e4ab4f73aa1697d7b6dc0caa0c17b2a187fb83b076dfc0234ec91f54R21)
removed the diagnostic style for "active but invalid" case: presumably,
it served as some sort of a cursor to show where to move on after the
diagnostics update, on the next `GoTo[Prev]Diagnostic` action call.

As this change went unchanged for some time, another approach is tested
now, to be more integrated with inline diagnostics: now, the active
state is cleared

Same as before this change, another `GoTo[Prev]Diagnostic` action call
will be needed to re-expand a new diagnostics, but this change makes
this expansion to happen after the cursor — before the change, Zed would
continue from the stale diagnostics.

Release Notes:

- Fixed active diagnostics becoming stale
2025-02-26 22:30:23 +02:00
Agus Zubiaga
d694458659
edit predictions: Rename edit prediction modes (#25657)
`auto` -> `stealth`
`eager_preview` -> `eager`

Release Notes:

- N/A

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-02-26 20:23:39 +00:00
Cole Miller
7a34dd9888
Save buffers after restoring hunks in the project diff (#25620)
This PR fixes a bug where using the project diff editor to restore hunks
from a file that's not open in its own buffer would cause those reverts
to be lost once the project diff drops its excerpts for that file.

The fix is to save the buffers after restoring them but before the
excerpts are (potentially) dropped. This is done for the project diff
editor only. If we fail to save the affected files, we add their buffers
to the active workspace, so that the reverted contents are preserved and
the user can try again to save them.

- [x] Get it working
- [x] Test
- [ ] ~~Clean up boolean soup~~

Co-authored-by: Max <max@zed.dev>

Release Notes:

- N/A
2025-02-26 15:16:17 -05:00
Michael Sloan
add7ae8052
Try to reveal selection changing issues in undo/redo via logging (#25676)
This will hopefully help debug #22692. I tried this for a while locally
and saw neither these logs nor the issue.

Release Notes:

- N/A
2025-02-26 19:48:15 +00:00
Cole Miller
eeac1a9287
Style filenames and paths in project diff buffer headers according to git status (#25653)
This substitutes for the icons that we previously kept in these headers.

cc @iamnbutler 

Release Notes:

- N/A
2025-02-26 14:43:10 -05:00
Conrad Irwin
b2a685f00a
Fix staging error reporting (#25630)
Closes #ISSUE

Release Notes:

- N/A
2025-02-26 12:38:04 -07:00
Danilo Leal
bab65011b4
edit prediction: Refine the stealth mode (#25599)
Release Notes:

- N/A

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
2025-02-26 12:50:11 -03:00
Max Brunsfeld
ebccef1aa4
Fix staging and unstaging of added and deleted files (#25631)
* When staging in a buffer whose file has been deleted, do not save the
file
* Fix logic for writing to index when file is deleted

Release Notes:

- N/A
2025-02-26 07:25:31 +00:00
Cole Miller
198f56c763
Fix gutter highlights not matching diff hunks near excerpt boundaries (#25600)
Release Notes:

- Fixed gutter highlights not matching diff hunks in multibuffers in
some cases

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2025-02-25 15:33:16 -08:00
Max Brunsfeld
d68d858a10
Fix crash in BlockMap::sync when there are inlay hints w/ newlines ri… (#25598)
Closes https://github.com/zed-industries/zed/issues/25377

Release Notes:

- Fixed a crash that could happen when typing in the assistant panel
with edit predictions enabled.

---------

Co-authored-by: Cole Miller <m@cole-miller.net>
2025-02-25 22:32:14 +00:00
smit
0559e1f348
editor: Fix panic when editor::SelectLargerSyntaxNode overflows excerpt in multi buffer (#25585)
Closes #25513

This PR handles case when `editor::SelectLargerSyntaxNode` expands
across excerpt boundaries and eventually crashes in multi buffer.

Release Notes:

- Fixed panic caused when `editor::SelectLargerSyntaxNode` is called
repetedly in multi buffer.

Co-authored-by: Ben Kunkle <ben.kunkle@gmail.com>
2025-02-26 01:05:00 +05:30
Peter Tripp
eebee4ab18
Add stop_at_indent for MoveToBeginningOfLine (#25428)
Add support for `stop_at_indent` option for MoveToBeginningOfLine and SelectToBeginningOfLine instead of mixing that with `stop_at_soft_wraps`.
Add emacs mapping for `alt-m` (`back-to-indentation`)
2025-02-25 12:03:14 -05:00
Cole Miller
45146b6f30
Implement staging of partially-staged hunks (#25520)
Closes: #25475 

This PR makes it possible to stage uncommitted hunks that overlap but do
not coincide with an unstaged hunk.

Release Notes:

- Made it possible to stage hunks that are already partially staged

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Max <max@zed.dev>
2025-02-24 23:13:13 -05:00
Agus Zubiaga
3f168e85c2
edit predictions: Invalidate cached settings and unset provider when set to none (#25505)
Fixes a few state mismatches when changing providers and other settings

Release Notes:

- edit predictions: Fix mismatch between status bar settings and editor
control settings
- edit predictions: Turn off as soon as `edit_prediction_provider` is
set to `none`

---------

Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-02-24 22:56:28 -03:00
Anthony Eid
3ee4edc404
Fix go to definition split (#24990)
Closes #24982 

Release Notes:

- Fix `GoToDefinitionSplit` action bug where split wouldn't happen if
definition was in the same active editor

---------

Co-authored-by: Dylan <dylwil3@gmail.com>
2025-02-24 18:46:13 -05:00
Conrad Irwin
7b277d2efd
Fix run indicators jumping when buffer content changes. (#25507)
Co-authored-by: Anthony Eid <hello@anthonyeid.me>

Release Notes:

- Fix run indicators jumping when content changes

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-02-24 22:57:54 +00:00
Conrad Irwin
63cfcc26fb
Fix jumping to multibuffer excerpts from deleted hunks (#25512)
Co-authored-by: Anthony Eid <hello@anthonyeid.me>

Release Notes:

- N/A

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-02-24 15:56:11 -07:00
Agus Zubiaga
2f7a62780a
edit predictions: Refine leading whitespace behavior (#25491)
Closes https://github.com/zed-industries/zed/issues/25406

### Problem

Users have been confused about requiring `alt-tab` instead of just `tab`
in cases where they don't have a completions menu open (see issue
above). When they insert a newline and are in leading whitespace, they
expect to be able to accept a prediction with just `tab`, but doing so
increasing the indentation instead.

This PR changes the behavior in so a modifier is only required if the
cursor isn't already at the right indentation level based on the
surrounding block. In this case, `tab` would increase the indentation
and the prediction would get interpolated, allowing the user to press
`tab` again to accept it.

We also updated the docs to break down this behavior:
https://github.com/zed-industries/zed/pull/25493

### Before


https://github.com/user-attachments/assets/91fe6193-dddd-43c1-8c26-0f4648bdc3fa

### After


https://github.com/user-attachments/assets/671041bf-bf22-46a3-8466-b19b3e7dd6a0


Release Notes:

- edit predictions: Do not require a modifier key when indentation is
correct according to its surrounding block

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-02-24 18:37:18 -03:00
Agus Zubiaga
ceb7fc2cb2
edit predictions: Split layout_edit_prediction popover (#25463)
This function has grown a lot and it was getting really hard to
navigate. This PR splits it into smaller methods and moves it into
`Editor` with the rest of the edit prediction popovers' code.

I think there are opportunities to consolidate the many popovers we
have, but we'll do that separately.

Release Notes:

- N/A
2025-02-24 16:16:19 -03:00
Mikayla Maki
ff6844300e
Git push/pull/fetch (#25445)
Release Notes:

- N/A

---------

Co-authored-by: Michael Sloan <mgsloan@gmail.com>
2025-02-24 18:29:52 +00:00
João Marcos
2b28b5969f
Remove unused variable distinguish_unstaged_diff_hunks (#25462)
Release Notes:

- N/A
2025-02-24 15:25:13 +00:00
Agus Zubiaga
72a9429ef6
edit predictions: Always position jump/accept popovers inside viewport (#25348)
https://github.com/user-attachments/assets/345961c5-9bcb-4ee5-80f2-03d5fd0741d3

Release Notes:

- edit prediction: Fixed jump/accept popover position for long lines

---------

Co-authored-by: Danilo <danilo@zed.dev>
2025-02-24 10:26:29 -03:00
Conrad Irwin
4067ae4b37
Fix stage/unstage buttons on new empty files (#25365)
Closes #ISSUE

Release Notes:

- N/A
2025-02-22 13:49:58 -07:00
Marshall Bowers
7a55da58d9
Revert "Hide the mouse when the user is typing in the editor (#25040)" (#25393)
This reverts commit a8610fbd13.

I've been seeing some reports of segmentation faults that appear to
point to this change as the culprit.

Closes #25366.

Release Notes:

- Community: Reverted #25040, so remove the corresponding entry from the
release notes.
2025-02-22 10:19:23 -05:00
Marshall Bowers
b9ca240242
editor: Fix compile errors after bad merge (#25374)
This PR fixes the compile errors after
https://github.com/zed-industries/zed/pull/25367 was merged without
passing CI.

Release Notes:

- N/A
2025-02-22 02:31:20 +00:00
Cole Miller
ef53f7af22
Fix issues with adjacent diff hunks (#25367)
Closes #ISSUE

Release Notes:

- Fixed being unable to toggle diff hunks with the mouse in some cases
2025-02-21 19:07:04 -05:00
Cole Miller
4118f42d61
Rename ExpandAllHunkDiffs to ExpandAllDiffHunks (#25369)
This is more consistent with the nomenclature in the rest of Zed.

Release Notes:

- Renamed the `editor::ExpandAllHunkDiffs` action to
`editor::ExpandAllDiffHunks`
2025-02-21 19:06:03 -05:00
João Marcos
5e1dd91ee5
Fix UI font size changes not applying (#25307)
Related to #24857.

Release Notes:

- N/A
2025-02-21 06:24:02 -03:00
Conrad Irwin
4871d3c9e7
New commit review flow in project diff view (#25229)
Closes #ISSUE

Release Notes:

- N/A

---------

Co-authored-by: Nate Butler <iamnbutler@gmail.com>
2025-02-21 06:52:34 +00:00
Max Brunsfeld
c31c638006
Fix relative indentation when pasting content copied from outside Zed (#25300)
Closes https://github.com/zed-industries/zed/issues/24914

Release Notes:

- Fixed incorrect indentation when pasting multi-line content that was
copied from another app.
2025-02-21 01:25:33 +00:00
Kirill Bulatov
ee1a559827
Improve expanded macro ergonomics (#25298)
Make the editor non-dirty and read-only.


Release Notes:

- Improve expanded macro ergonomics
2025-02-21 00:40:08 +00:00
Michael Sloan
30850fe3bd
Add editor actions for moving and selecting to next / previous excerpt (#25299)
Covers part of #5129 by adding `MoveToStartOfExcerpt`,
`MoveToEndOfExcerpt`, `SelectToStartOfExcerpt`, and
`SelectToEndOfExcerpt`.

No default linux bindings yet as it's unclear what to use. Currently,
`ctrl-up` / `ctrl-down` scroll up and down by one line (see #13269).
Considering changing the meaning of those.

Mac:

* Previously `cmd-up` and `cmd-down` were `editor::MoveToBeginning` and
`editor::MoveToEnd`. In singleton editors these will behave the same as
before. In multibuffers, they will now step through excerpts instead of
jumping to the beginning / end of the multibuffer.

* `cmd-home` and `cmd-end`, often typed as `cmd-fn-left` and
`cmd-fn-right` are now `editor::MoveToBeginning` and
`editor::MoveToEnd`. This is useful in multibuffers.

Release Notes:

- Mac: `cmd-up` now moves to the previous
multibuffer excerpt start, and `cmd-down` moves to the next multibuffer
excerpt end. Within normal buffers these behave the same as before, moving
to the beginning or end.
2025-02-21 00:23:20 +00:00
Kirill Bulatov
5ae93ce68d
Add initial inline diagnostics support (#25297)
https://github.com/user-attachments/assets/eb881707-e575-47ef-9ae0-67d8085d8065

Closes https://github.com/zed-industries/zed/pull/22668
Closes https://github.com/zed-industries/zed/issues/4901

Takes https://github.com/zed-industries/zed/pull/22668 and fixes all
review items on top.
Inline diagnostics are disabled by default, but can be enabled via
settings permanently, or temporarily toggled with the `editor:
ToggleInlineDiagnostics` action and the corresponding editor menu item
<img width="242" alt="image"
src="https://github.com/user-attachments/assets/8e177511-4626-4434-902b-d6aa4d3fafd0"
/>

Inline diagnostics does not show currently active diagnostics group, as
it gets inline into the editor too, inside the text.
Inline git blame takes precedence and is shown instead of the
diagnostics, edit predictions dim the diagnostics if located on the same
line.

One notable drawback of the implementation is the inability to wrap,
making inline diagnostics cut off the right side:


![image](https://github.com/user-attachments/assets/6e87268a-b51a-4a2b-8b8d-01d932c62fea)

(same as inline git blame and other elements to the right of the text)
Given that it's disabled by default and go to next/prev diagnostics will
show them better, seems fine to leave in the first iteration.


Release Notes:

- Added initial inline diagnostics support

---------

Co-authored-by: Paul J. Davis <paul.davis@tiledb.com>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-02-20 23:39:47 +00:00
itsaphel
191a1d7b10
edit prediction: Don't show and discard completion if toggled off in the buffer (#24927)
Discards an inline completion when it's toggled to off (using, say, a
keyboard shortcut). This matches the behaviour in VS Code and JetBrains,
and I think is a bit more intuitive.

(https://github.com/zed-industries/zed/discussions/24895)

Release Notes:

- N/A
2025-02-20 17:02:31 -03:00
Thomas Mickley-Doyle
a8610fbd13
Hide the mouse when the user is typing in the editor (#25040)
Closes https://github.com/zed-industries/zed/issues/4461

This PR improves the coding experience by hiding the mouse while the
user is typing so it does not accidentally get in their way, making it
challenging to ready characters in the editor.

Release Notes:

- The following PR hides the cursor when the user is typing by adding a
new cursor style called `None`.
- Assuming the user does not move the mouse, it will stay hidden until
it is moved again.


https://github.com/user-attachments/assets/6ba9f2ee-b9f3-4595-81e4-e9d986da4a39

---------

Co-authored-by: Agus <agus@zed.dev>
Co-authored-by: Peter Tripp <peter@zed.dev>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2025-02-20 15:54:01 -03:00