Commit graph

19609 commits

Author SHA1 Message Date
smit
1fa105eaa5
docs: Fix selection highlight default value (#25134)
Changed default debounce value in docs to match default settings.

Release Notes:

- N/A
2025-02-19 13:27:49 +05:30
smit
043c4ed296
editor: Fix highlight selection panic (#25141)
Use the latest selection state for highlighting instead of the state
before debounce.

Release Notes:

- N/A
2025-02-19 12:50:49 +05:30
Kirill Bulatov
e57b9e5f83
Ignore selections persistence for multi buffer editors (#25140)
Follow-up of https://github.com/zed-industries/zed/pull/25083

Release Notes:

- N/A
2025-02-19 06:42:22 +00:00
Conrad Irwin
13da468e22
Fix for #25039 (#25138)
Release Notes:

- vim: Fix crash in `ci{`
2025-02-19 06:24:54 +00:00
Conrad Irwin
1678e3cbf1
Fix clicking on file links in editor (#25117)
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
2025-02-18 22:54:35 -07:00
Ben Kunkle
ebbc6a9752
Highlight super and this as keywords in JS/TS/TSX (#25135)
Closes #24951

We were highlighting both as `@variable.special` however, they are
_techinically_ keywords and other editors (VSCode/WebStorm) seem to
highlight them as keywords as well.

Release Notes:

- N/A
2025-02-19 05:53:16 +00:00
Ben Kunkle
bb600acaa1
Set base highlight for identifiers in go to variable highlight color (#25128)
Closes #24947 

Release Notes:

- N/A
2025-02-19 01:54:51 +00:00
Marshall Bowers
372aaecdb4
language_model_selector: Authenticate all providers up front (#25123)
This PR fixes an issue where configured language model providers would
not show up unless the configuration view was opened.

The problem was that we were filtering unauthenticated language model
providers out of the language model selector, but would only
authenticate the active provider when the selector loaded.
Authenticating the rest of the providers was deferred until the
configuration view was opened for the first time.

Closes https://github.com/zed-industries/zed/issues/21821.

Release Notes:

- Fixed an issue where configured languages models were not showing up
in the language model selector until the configuration view was opened
for the first time.
2025-02-19 01:40:07 +00:00
Marshall Bowers
7a6b652ebc
language_model: Return AuthenticateErrors from LanguageModelProvider::authenticate (#25126)
This PR updates the `LanguageModelProvider::authenticate` method to
return an `AuthenticateError` instead of an `anyhow::Error`.

This allows us to model the "credentials not found" state explicitly as
`AuthenticateError::CredentialsNotFound`, which enables the caller to
check for this state and act accordingly.

Planning to use this in #25123 to silence errors about missing
credentials when authenticating providers in the background.

Release Notes:

- N/A
2025-02-19 00:01:48 +00:00
Danilo Leal
2627a5fdbe
assistant: Improve the language model selector (#25125)
This PR includes change such as:

- Ensures the popover width is fixed/not dancing around
- Ensures the popover is not obscuring the trigger in the buffer and
terminal inline assistant scenarios
- Removes ellipsis from the trigger button label
- Ensures the scrollbar doesn't hide the check icon

| Terminal | Prompt Editor | Buffer |
|--------|--------|--------|
| ![Screenshot 2025-02-18 at 8 43
46 PM](https://github.com/user-attachments/assets/9cdfbaf1-f27e-4f48-877e-9cf61767ecee)
| ![Screenshot 2025-02-18 at 8 43
49 PM](https://github.com/user-attachments/assets/7abf9be2-bd2a-43d7-9a5d-d665e7e9fda3)
| ![Screenshot 2025-02-18 at 8 43
52 PM](https://github.com/user-attachments/assets/017bbdb3-185a-4bf6-9005-018ecafef9dd)
|

Release Notes:

- N/A
2025-02-18 21:01:09 -03:00
Marshall Bowers
a6006afdd7
language_model_selector: Fix variable name (#25121)
This PR fixes an inaccurate variable name that I noticed in the language
model selector.

Release Notes:

- N/A
2025-02-18 23:10:47 +00:00
Kirill Bulatov
92f128ebb0
Do not fail hard on selection persistence if the editor is removed (#25120)
Follow-up of https://github.com/zed-industries/zed/pull/25083

Follows practices from editors' scroll position persisting:
5a05b7461e/crates/editor/src/persistence.rs (L200)
and do not fail hard if the editor with the ID given does not exist.
Also add the problematic IDs into the error context to see them in the
error logs.

Release Notes:

- N/A
2025-02-18 22:52:23 +00:00
Marshall Bowers
98ea659af6
assistant2: Fix thread history only working in one Zed window (#25119)
This PR fixes an issue where the thread history would only work in one
Zed window at a time.

The backing LMDB database can only be opened once per Zed instance.
However, the `ThreadStore` has one instance per Zed window.

To fix this, we need to create the `heed` environment once and store it
as a global, and then reference the same environment across all of the
`ThreadStore`s.

Release Notes:

- N/A
2025-02-18 22:44:43 +00:00
João Marcos
d0816ef2e2
edit predictions: Fix fold not expanding after jump (#25116)
Closes #24938.

Release Notes:

- Edit predictions: Fix fold not expanding after jump
2025-02-18 18:55:00 -03:00
Agus Zubiaga
6885b28c22
assistant2: Deploy inline assistant in PromptEditor (#25094)
Release Notes:

- N/A

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-02-18 18:29:12 -03:00
Conrad Irwin
48f87a8d9a
Don't open file finder menu on command (#25097)
Closes #24740

Release Notes:

- Don't open the split menu in the file finder when command is pressed
2025-02-18 14:27:10 -07:00
Danilo Leal
bff1548b48
assistant2: Add file icons for mentioned creases (#25111)
This PR makes the mentioned file creases/buttons use `FileIcons`.

<img width="700" alt="Screenshot 2025-01-21 at 11 20 49 AM"
src="https://github.com/user-attachments/assets/876da534-c11a-4d13-af82-a5948863f954"
/>

Release Notes:

- N/A

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-02-18 18:22:01 -03:00
Conrad Irwin
60a44359e4
Terminal mouse improvements (#25104)
Closes #24911
Closes #17983
Closes #7073

Release Notes:

- Terminal: Fix cmd-click on links/files when terminal is not focused
- Terminal: Remove hover treatment after Zed hides/re-opens

---------

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2025-02-18 13:10:10 -08:00
Michael Sloan
b1872e3afd
cx.background_executor().spawn(...) -> cx.background_spawn(...) (#25103)
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
2025-02-18 20:30:33 +00:00
Piotr Osiewicz
f606b0641e
workspace: Prevent user from undoing persistent session deserialization (#25106)
Closes #21846

Release Notes:

- Fixed a bug that made it possible to undo changes in dirty
deserialized buffer (with `restore_unsaved_buffers: true`)
2025-02-18 19:49:39 +00:00
Cole Miller
529c65276e
Revert gutter stripes as indicator of hunk staged status (#25089)
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
2025-02-18 13:20:39 -05:00
Agus Zubiaga
737b177ab5
Switch to columnar selection by pressing alt-shift while mouse is down (#25096)
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
2025-02-18 14:49:13 -03:00
Marshall Bowers
c10ac31866
theme: Don't log errors for missing themes until extensions have loaded (#25098)
This PR makes it so we don't log errors for missing themes or icon
themes until after the extensions have been loaded.

Currently, if you are using a theme that is defined in an extension it
is common to see one or more "theme not found" errors in the logs. This
is the result of us having to initialize the theme before the extensions
have actually finished loading.

This means that a theme that _may_ exist once extensions load is
considered non-existent before they have loaded.

To that end, we now wait until the extensions have loaded before we
start logging errors if we can't find the theme or icon theme.

Closes https://github.com/zed-industries/zed/issues/24539.

Release Notes:

- Reduced the number of "theme not found" and "icon theme not found"
errors in the logs for themes provided by extensions.
2025-02-18 17:47:25 +00:00
Danilo Leal
1e255e41cc
assistant2: Show token count in the Prompt Editor view (#25091)
Release Notes:

- N/A

---------

Co-authored-by: Agus Zubiaga <hi@aguz.me>
2025-02-18 13:24:15 -03:00
Danilo Leal
8a7565e04b
Add small improvement to the theme picker footer (#25088)
- Always start a button's label with an imperative verb
- Use the `ArrowUpRight` icon when the button opens an external link

<img width="700" alt="Screenshot 2025-01-21 at 11 20 49 AM"
src="https://github.com/user-attachments/assets/383d9bad-2756-4e85-acad-4ed956f541cb"
/>

Release Notes:

- N/A
2025-02-18 13:24:06 -03:00
Marshall Bowers
8e7cad7848
theme: Return structured errors when a theme is not found (#25090)
This PR updates the `ThemeRegistry` to return structured errors from the
`get` and `get_icon_theme` methods (which are used to retrieve themes
and icon themes, respectively).

We want to be able to carry the name of the theme that was not found as
state on the error, which is why we use a `Result` and not an `Option`.
However, we also want to be able to accurately identify when the error
case is "not found" so we can take appropriate action, based on the
circumstances.

By using a custom error type instead of an `anyhow::Error`, we get both.

There isn't any functional change in this PR. This just sets us up for
future improvements in this error.

Release Notes:

- N/A
2025-02-18 10:49:55 -05:00
Cole Miller
76f501af71
git: Don't load shallow HEAD text of symlinks (#25058)
For symlinks, return `None` from `load_committed_text` as we do from
`load_index_text` ever since #10037.

Release Notes:

- Fixed diff hunks appearing in unchanged symlinked files
2025-02-18 15:18:23 +00:00
Cole Miller
9ef0501853
file_finder: Remove common segments of long paths in search results (#25049)
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>
2025-02-18 10:09:15 -05:00
Kirill Bulatov
80458ffb96
Persist selections for editors (#25083)
Part of https://github.com/zed-industries/zed/issues/7371
Closes https://github.com/zed-industries/zed/issues/12853

Release Notes:

- Started to persist latest selections for editors, to restore those on
restart
2025-02-18 14:27:00 +00:00
Danilo Leal
b34037876e
terminal: Change context menu item label (#25085)
Super subtle, but when I initially saw just "Close", I got weirded out
asking myself "why there's a menu item to close the context menu?", to
only then realize that it didn't close the menu, but the terminal _tab_.
Might be obvious, because that's how buffer tabs are labled, but I don't
know, it feels like the redundancy here is overall positive.

Release Notes:

- N/A
2025-02-18 11:14:10 -03:00
Danilo Leal
295e486113
edit prediction: Update disabled globs link in the onboarding modal (#25084)
Release Notes:

- N/A
2025-02-18 10:45:25 -03:00
Antonio Scandurra
00bb9a4e92
Fix LSP rename in Go (#25073)
Some language servers report version 0 even if the buffer hasn't been
opened yet. We detect this case and treat it as if the version was
`None`.

Closes #23706

Release Notes:

- Fixed a bug that prevented renames for some languages.
2025-02-18 10:37:58 +00:00
João Marcos
b4fc127e49
editor: Disable "Open in Terminal" when it's not possible (#25059)
When impossible to trigger action, the button should be disabled.

Release Notes:

- N/A
2025-02-18 04:07:04 -03:00
Max Brunsfeld
813d870a03
Bump Tree-sitter for bug fixes affecting YAML parser loaded via WASM (#25054)
Closes https://github.com/zed-industries/zed/issues/24742
Closes #24632

This PR bumps Tree-sitter to bring in bug fixes:
* https://github.com/tree-sitter/tree-sitter/pull/4218
* https://github.com/tree-sitter/tree-sitter/pull/4213
* https://github.com/tree-sitter/tree-sitter/pull/4210

I've also bumped Wasmtime and wit-bindgen, since the new Tree-sitter
uses a newer wasmtime.

Release Notes:

- Fixed a parsing bug that caused memory leaks and crashes when using
the Ansible extension

---------

Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-02-17 21:29:27 -08:00
João Marcos
8942e657aa
add more tests to editor::SelectAllMatches (#25060)
Release Notes:

- N/A
2025-02-18 05:07:57 +00:00
Cole Miller
06726a28d3
Revert splitting display diff hunks (#25020)
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
2025-02-17 23:45:37 -05:00
João Marcos
a8de6af641
Fix editor::SplitSelectionIntoLines adding an extra line at the end (#25053)
Closes #4795

Release Notes:

- Fixed `editor::SplitSelectionIntoLines` adding an extra line at end
of selection
2025-02-18 03:23:48 +00:00
Ben Kunkle
12aa270b9a
Fix TypeScript block indenting when using allman style (#25051)
Closes #24976 

Release Notes:

- Fixed an issue where writing TypeScript using Allman style would
result in incorrect auto-indent behavior
2025-02-18 01:15:10 +00:00
Dylan
bb53ad9862
Only allow save_as for pane if can_save_as is true (#25028)
When saving an item, some logic is done to determine whether one can
save it. In the special case where the intent is to `SaveAs`, it was
previously allowed to proceed as long as the buffer was a singleton
(presumably since it only makes sense to provide a save path for a
single file). However, we need to _also_ check that this item can be
"saved as" at all.

For this, we resurrect the `ItemHandle`/`Item` trait method
`can_save_as`. We have given it the default implementation of returning
`false`, and then overridden this in the implementation for
`TerminalView`.

Closes #25023


Release Notes:

- Fixed crash when trying to save terminal buffer

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-02-17 16:01:56 -07:00
Danilo Leal
62a11b047d
ui: Remove track_focus method from Picker render (#25043)
Follow-up to: https://github.com/zed-industries/zed/pull/25025

Removing the `track_focus` method fix the focus hijack that we
introduced in the previous PR. cc @0xtimsb
Also, I don't see any immediate affect in the actual scrollbar behavior
without this! Holler if that's not the case.

Release Notes:

- N/A
2025-02-17 19:18:12 -03:00
Osvaldo
e068c7b4b4
vim: Update anyquotes and anybrackets to behave like mini.ai plugin (#24167)
### Overview
This PR improves the existing
[mini.ai‐like](https://github.com/echasnovski/mini.ai) text-object logic
for both “AnyQuotes” (quotes) and “AnyBrackets” (brackets) by adding a
multi‐line fallback. The first pass searches only the current line for a
best match (cover or next); if none are found, we do a multi‐line pass.
This preserves mini.ai's usual “line priority” while ensuring we can
detect pairs that start on one line and end on another.

### What Changed
1. Brackets
- Line-based pass uses `gather_line_brackets(map, caret.row()) `to find
bracket pairs `((), [], {}, <>) `on the caret’s line.
- If that fails, we call `gather_brackets_multiline(map)` to single‐pass
scan the entire buffer, collecting bracket pairs that might span
multiple lines.
- Finally, we apply the mini.ai “**cover or next**” logic
(`pick_best_range`) to choose the best.
2.  Quotes
  - Similar line-based pass with `gather_line_quotes(map, caret.row())`.
- If no local quotes found, we do a multi‐line fallback with
`gather_quotes_multiline(map)`, building a big string for the whole
buffer and using naive regex for "...", '...', and `...`.
  - Also preserves “inner vs. outer” logic:
- For inner (e.g. `ciq`), we skip bounding quotes or brackets if the
range is at least 2 characters wide.
    - For outer (`caq`), we return the entire range.
3. Shared “`finalize`” helpers
- `finalize_bracket_range` and `finalize_quote_range` handle the “inner”
skip‐chars vs. “outer” logic.
  - Both rely on the same “line first, then full fallback” approach.

### Why This Matters
- **Old Behavior**: If you had multi‐line brackets { ... } or multi‐line
quotes spanning multiple lines, they weren’t found at all, since we only
scanned line by line. That made text objects like ci{ or ciq fail in
multi-line scenarios.
- **New Behavior**: We still do a quick line pass (for user‐friendly
“line priority”), but now if that fails, we do a single‐pass approach
across the entire buffer. This detects multi‐line pairs and maintains
mini.ai’s “cover‐or‐next” picking logic.

### Example Use Cases
- **Curly braces:** e.g., opening { on line 10, closing } on line 15 →
previously missed; now recognized.
- **Multi‐line quotes**: e.g., "'Line 1\nLine 2', no longer missed. We
do gather_quotes_multiline with a naive regex matching across newlines.

### Tests
- Updated and expanded coverage in:
  - test_anyquotes_object:
    - Includes a multi-line '...' test case.
- E.g. 'first' false\n<caret>string 'second' → ensuring we detect
multi‐line quotes.
  - test_anybrackets_object:
- Verifies line‐based priority but also multi‐line bracket detection.
- E.g., an open bracket ( on line 3, close ) on line 5, which used to
fail.

### Limitations / Future Enhancements
- **Escaping**: The current approach for quotes is naive and doesn’t
handle escape sequences (like \") or advanced parser logic. For deeper
correctness, we’ll need more advanced logic, this is also not supported
in the original mini.ai plugin so it is a known issue that won't be
attended for now.

### Important Notes
- Fix for the bug: https://github.com/zed-industries/zed/issues/23889
this PR addresses that bug specifically for the AnyQuotes text object.
Note that the issue still remains in the built-in motions (ci', ci",
ci`).
- Caret Position Differences: The caret position now slightly deviates
from Vim’s default behavior. This is intentional. I aim to closely mimic
the mini.ai plugin. Because these text objects are optional
(configurable via vim.json), this adjusted behavior is considered
acceptable and in my opinion the new behavior is better and it should be
the default in vim. Please review the new tests for details and context.
- Improved Special Cases: I’ve also refined how “false strings” in the
middle and certain curly-bracket scenarios are handled. The test suite
reflects these improvements, resulting in a more seamless coding
experience overall.

### References:
- Mini.AI plugin in nvim: https://github.com/echasnovski/mini.ai

Thank you for reviewing these changes!

Release Notes:

- Improve logic of aq, iq, ab and ib motions to work more like mini.ai
plugin
2025-02-17 14:55:48 -07:00
Danilo Leal
a99696b95f
pane: Disable the "Close..." controls depending on certain scenarios (#25037)
Closes https://github.com/zed-industries/zed/issues/12471

- Disables "Close Others" if there's just one tab
- Disables "Close Left"/"Close Right" if the above is true or if there's
no tabs to the left/right side of the active tab

Release Notes:

- N/A
2025-02-17 18:01:13 -03:00
Danilo Leal
dc11a61ff8
assistant: Improve language model selector design (#25036)
Closes https://github.com/zed-industries/zed/issues/23234

This PR adds a scrollbar to the model selector, and ensures no label
(model and provider name) is cut off.

Release Notes:

- N/A
2025-02-17 17:12:46 -03:00
Michael Sloan
aa4c438f83
Use Vec for KeyContext instead of SmallVec (#24916)
In Zed the key context almost always has more than 1 entry, so use of
`SmallVec` is just adding overhead.

In Zed while using the editor this typically has more than 8 entries.
Since `ContextEntry` is 48 bytes, if this were made to be a
`SmallVec<[ContextEntry; 10]>` then it would use 480 bytes on the stack,
which to me seems like a lot to be copying. So, instead opting to just
use `Vec`

Release Notes:

- N/A
2025-02-17 12:43:28 -07:00
Danilo Leal
f2bc3d3738
assistant: Add model selector to the Context Editor (#25032)
This PR also removes everything related with the model selector from the
Context Editor toolbar.

Release Notes:

- N/A
2025-02-17 16:29:42 -03:00
Richard Hao
f833a01a7e
copilot: Add support for Gemini 2.0 Flash model to Copilot Chat (#24952)
Co-authored-by: Peter Tripp <peter@zed.dev>
2025-02-17 19:25:38 +00:00
smit
3e9722685b
editor: Highlight all matching occurrences of text in selection (#24835)
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>
2025-02-18 00:51:14 +05:30
Max Brunsfeld
1e1b637b50
Fix handling of empty blocks in BlockMap::chunks (#25031)
Closes https://github.com/zed-industries/zed/issues/23391

Release Notes:

- Fixed a bug that sometimes caused incorrect syntax highlighting when
deploying the inline assistant.
2025-02-17 11:20:19 -08:00
Danilo Leal
69477dfd8c
ui: Add show_scrollbar method to Picker (#25025)
Now, you can pass `show_scrollbar` to Picker that implement a
`uniform_list`. If that's on, the scrollbar should auto-hide if you move
your focus elsewhere. By default, this method is turned off.

Release Notes:

- N/A

---------

Co-authored-by: smit <0xtimsb@gmail.com>
2025-02-17 16:16:48 -03:00
Agus Zubiaga
478bccadd6
edit predictions: Handle no keybind for preview (#25015)
If the user removes all modified keybinds in `edit_prediction_conflict`,
the preview bar above the completions menu would disappear. This PR
handles that case slightly better by still showing the 1-line preview
(which they might accept via an unmodified keybind) and hides the `|
Preview ⌥` section since it's impossible to invoke in this case.

Release Notes:

- Handle `edit_prediction_conflict` context without modified keybinds
for `AcceptEditPrediction`
2025-02-17 16:00:20 -03:00