Closes#26002
Release Notes:
- Added `multibuffer` key context.
- `cmd-down` and `cmd-shift-down` on Mac now moves to the end of the
last line of a singleton buffer instead of the beginning. In
multibuffers, these now move to the start of the next excerpt.
- Fixed `vim::PreviousSectionEnd` (bound to `[ ]`) to move to the
beginning of the line, matching the behavior of `vim::NextSectionEnd`.
- Added `editor::MoveToStartOfNextExcerpt` and
`editor::MoveToEndOfPreviousExcerpt`.
205f9a9f03/crates/editor/src/element.rs (L1643)
Due to the snippet above, Zed is supposed to have `row` larger or equal
to `start_row` here:
205f9a9f03/crates/editor/src/element.rs (L1694)
yet the panic were reported when clicking in the project diff.
That project diff has a lot of highlighting happening already, so the PR
disables inline diagnostics within a git diff view.
Release Notes:
- N/A
This PR adds a few more hunk style settings that flips the emphasis.
Normally, the concept at Zed has been that the project diff should
emphasize what's going into the commit. However, this leads to a problem
where the default state of all diff hunks are in the non-emphasized
state, making them hard to see and interact with. Especially on light
themes. This PR is an experiment in flipping the emphasis states. Now
the project diff is more like a queue of work, with the next "job" (hunk
to be evaluated) emphasized, and the "completed" (staged) hunks
deemphasized. This fixes the default state issue but is a big jump from
how we've been thinking about it. So here we can try it out and see how
it feels :)
Release Notes:
- Git Beta: Added hunk style settings to emphasize the unstaged state,
rather than the staged state.
Release Notes:
- Git Beta: Fixed a bug where discarding a hunk in the project diff view
performed two concurrent saves of the buffer.
- Git Beta: Fixed an issue where diff hunks appeared in the wrong state
after failing to write to the git index.
We were iterating over the row range of a hunk, and inserting into a
hash map for every row.
Release Notes:
- Fixed a performance problem when a large diff hunk was displayed in an
editor.
This PR adds the `git.hunk_style` setting, allowing setting an alternate
style for hunks – specifically the rendering of unstaged hunks.
It has 2 options:
- `transparent` (unstaged hunks are more transparent/less opaque than
staged hunks)
- `pattern (unstaged hunks are indicated by a visual pattern)
We'll possibly explore a VSCode-style "don't show staged hunks", but the
complexity it adds is a bit out of scope for now.
Transparent:

Pattern:

Release Notes:
- Git Beta: Added `git.hunk_style` setting to allow toggling between git
hunk visual styles.
Closes#22999
# Problem
Currently, the default soft wrap mode of an editor is determined by
reading the language-specific settings of the language _at offset zero_
in the editor's (multi)buffer. While this provides a way to pick a
single soft wrap mode for a multi-language multibuffer, it's a bad
choice for a single-buffer multibuffer that begins with a different
embedded language. For example, Markdown with frontmatter:
```markdown
---
my_front_matter
---
# Hello World
```
Setting this in config:
```json
"languages": {
"Markdown": { "soft_wrap": "bounded" }
},
```
Will not soft wrap the Markdown file as the language at offset zero is
YAML.
# Solution
Instead of using the language at offset zero, use the language of the
first buffer in the multibuffer (the buffer at offset zero). This gives
better behavior for single-buffer editors, and a similar default for
multi-language multibuffers as before.
# Testing
All existing `editor` crate tests pass, but I would appreciate any
guidance for where best to add additional testing.
Release Notes:
- Fixed soft_wrap setting not applying to buffers starting with a
different language
---------
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Closes#25951
Release Notes:
- git: Update "enter" in the list of changed files to preserve focus. If
you want the old behaviour, hit enter twice.
- git: Follow the cursor, not the scroll anchor, in the list. Although
the scroll anchor was nice for passive scrolling, it broke if you had
changed the overflow scroll settings.
Closes#10167
This is take 2 on https://github.com/zed-industries/zed/pull/2341 which
was closed due to lack of migrator.
This PR contains rename of following keymap actions:
```sh
1. ["editor::GoToPrevHunk", { "center_cursor": true }] -> ["editor::GoToPreviousHunk", { "center_cursor": true }]
2. "editor::GoToPrevDiagnostic" -> "editor::GoToPreviousDiagnostic"
3. "editor::ContextMenuPrev" -> "editor::ContextMenuPrevious"
4. "search::SelectPrevMatch" -> "search::SelectPreviousMatch"
5. "file_finder::SelectPrev" -> "file_finder::SelectPrevious"
6. "menu::SelectPrev" -> "menu::SelectPrevious"
7. "editor::TabPrev" -> "editor::Backtab"
```
Release Notes:
- Renamed several keymap actions for consistency (e.g., `GoToPrevHunk` →
`GoToPreviousHunk`, `TabPrev` → `Backtab`). Your existing configured
keybindings will still work. You can click **"Backup and Update"** at
the top of your keymap file to easily update to the new actions.
Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
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
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>
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.
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
Release Notes:
- Fixed gutter highlights not matching diff hunks in multibuffers in
some cases
---------
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
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>
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>
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
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.
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.
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>
Closes #ISSUE
Release Notes:
- Rename `editor::RevertSelectedHunks` and `editor::RevertFile` to
`git::Restore` and `git::RestoreFile` for consistency with git
Closes https://github.com/zed-industries/zed/issues/10122
Closes https://github.com/zed-industries/zed/issues/25034
When formatting buffers or reloading them after they change on disk, we
performed a diff between the buffer's current contents and the new
content. We need this diff in order preserve the positions of cursors
and other decorations when updating the buffer's text.
In order to handle changes within lines, we would previously compute a
*character-wise* diff. This was extremely expensive for large files.
This PR gets rid of the character-wise diff, and instead performs a
normal line-wise diff. Then, for certain replace hunks, we compute a
secondary word-based diff. Also, I've switched to the
[`imara-diff`](https://github.com/pascalkuthe/imara-diff) crate, instead
of `similar`.
Release Notes:
- Fixed a hang that could occur when large files were changed on disk or
formatted.
The language::markdown crate had been superceded by markdown::Mardown.
After #25117, the only two remaining use-cases were rendering git commit
messages (which are arguably not really markdown) and the signature help
(which is definitely not markdown).
Updated the former to use the new markdown component, and the latter to
do syntax highlighting manually.
Release Notes:
- Allow selecting the commit message in git commits
Closes#22610
This PR fixes the invisible scroll thumb or very tiny scroll thumb when
viewing long or wide files.
The difference between `track_bounds` (imagine scrollbar total height)
and `thumb_size` is the remaining area, which maps to the total height
of the page for scrolling to work as expected. This is already accounted
for. That means we can adjust the thumb size as needed, and the
remaining height/width will be mapped correctly.
So, we can simply use define a minimum size for the thumb and handle
cases where the track bounds are smaller than the defined minimum size.
In such cases, the scrollbar will take up the full height/width of the
track bounds. This is handled mainly to avoid panics in extreme edge
cases. Practically, at such small heights/widths, users are unlikely to
attempt scrolling.
Before:
https://github.com/user-attachments/assets/cf2edf03-8b9a-4678-b3c6-9dcbd01e5db8
After:
https://github.com/user-attachments/assets/e9496a44-3e7d-4be7-b892-2762cccd9959
Release Notes:
- Fixed issue where scroll thumb was invisible or too small when viewing
long or wide files.
This reverts commit 9ef0501853 due to a
panic.
```
{
"thread": "main",
"payload": "9 is not a valid char boundary in path \"crates/…/LiveKitBridge/\"",
"location_data": {
"file": "crates/file_finder/src/file_finder.rs",
"line": 646
}
}
```
Release Notes:
- N/A
Closes#18641
Contributes: #13194
Release Notes:
- Open LSP documentation file links in Zed not the system opener
- Render completion documentation markdown consistently with
documentation markdown
Done automatically with
> ast-grep -p '$A.background_executor().spawn($B)' -r
'$A.background_spawn($B)' --update-all --globs "\!crates/gpui"
Followed by:
* `cargo fmt`
* Unexpected need to remove some trailing whitespace.
* Manually adding imports of `gpui::{AppContext as _}` which provides
`background_spawn`
* Added `AppContext as _` to existing use of `AppContext`
Release Notes:
- N/A
We've decided to go in a different direction on indicating the staged
status of hunks, so go back for now to a world where we don't display
staged and unstaged hunks differently outside the (still gated) project
diff editor.
cc @iamnbutler
This reverts commit 8c202b3b09.
Release Notes:
- N/A
We begin a columnar selection when we drag the mouse while holding
`alt-shift`. This PR makes it possible to start the selection and then
turn it into columnar by pressing `alt-shift`.
Fixes#5372
Release Notes:
- Support switching to columnar selection by pressing `alt-shift` while
mouse is down
This PR makes progress on #7711 by identifying any common prefix of the
paths in the file finder's search results, and replacing the "interior"
of that prefix---every path segment but the first and last---with `...`,
when a heuristic indicates that the longest path would otherwise
overflow the modal.
The elision is not applied to any segment that contains a match for the
search query.
There may be more work to do on #7711 in the case of long result paths
that do not share a significant common prefix.
Release Notes:
- Improved display of long paths in the file finder modal
Co-authored-by: Max <max@zed.dev>
This PR reverts two recent commits that changed our gutter highlights to
mark separately the deleted and added portions of an expanded
modification hunk. It returns to the previous status quo where the
gutter highlight for an expanded modification hunk has the same color
for the deleted and added portions.
Release Notes:
- N/A
Closes#12635
- [x] Get it working
- [x] Disable for multi cursor
- [x] Disable for vim visual line selection
- [x] Add setting to disable it
- [x] Add scrollbar marker
- [x] Handle delete state capturing selection
Preview:
https://github.com/user-attachments/assets/a76cde64-4f6c-4575-91cc-3a03a954e7a9
Release Notes:
- Added support to highlight all matching occurrences of text within the
selection in editor.
---------
Co-authored-by: Agus Zubiaga <agus@zed.dev>
Co-authored-by: Danilo <danilo@zed.dev>