Commit graph

1331 commits

Author SHA1 Message Date
Agus Zubiaga
82f793144e
edit predictions: Add enabled_in_assistant setting (#25767)
Release Notes:

- edit predictions: Add `enabled_in_assistant` setting
2025-02-27 18:52:45 +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
Kirill Bulatov
e8ef36edcc
Add a way to toggle inlay hints with modifiers (#25752) 2025-02-27 17:53:10 +02:00
smit
1f52aab7c7
buffer: Fix panic when multi-byte character is used in languages like Swift (#25739)
Closes #25471

In languages like Swift, names can be concatinated in form like `class
Example: UI`, notice here `Example` and `:` are two different words.
Before, `name_ranges`translation of above text would look like:

```
"class" -> [0..5]
" Example" -> [5..13] (Spaces are intentional)
"e:" -> [12..14] (This is incorrect, and should be ":" -> [13..14])
" UI" -> [14..16]
```

Because this translation does not account for concatinated words, this
might affect queries, but most importantly this panics when multi-byte
character (`ф`) is used in place of `e`, as it then tries to access
index which lies inside that multi-byte. For example, it panics on
`class Examplф: UI`.

---

This PR fixes this by handing concatinated words when calculating
`name_ranges`.

Now, the corrected ranges will look like:

```
"class" -> [0..5]
" Example" -> [5..13]
":" -> [13..14] (Now it's correct)
" UI" -> [14..16]
```

and for multi-byte character

```
"class" -> [0..5]
" Examplф" -> [5..14] (Notice ф takes two bytes)
":" -> [14..15]
" UI" -> [15..17]
```

This way, it no longer tries to access a previous index, preventing a
panic when that index contains a multi-byte character.

Release Notes:

- Fixed a panic when Cyrillic characters are used in languages like
Swift.
2025-02-27 16:27:07 +05:30
Marshall Bowers
6a1c104522
language_settings: Add auto alias for subtle edit prediction mode (#25686)
This PR makes `auto` an alias for the `subtle` edit prediction mode.

Right now I'm in a state where I can't have valid settings in both
development and Nightly because the settings values are disparate.

Release Notes:

- N/A
2025-02-26 22:06:17 +00: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
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
Eli Kaplan
a8d56877ee
copilot: Support HTTP/HTTPS proxy for Copilot language server (#24364)
Closes #6701 (one of the top ranking issues as of writing)

Adds the ability to specify an HTTP/HTTPS proxy to route Copilot code
completion API requests through. This should fix copilot functionality
in restricted network environments (where such a proxy is required) but
also opens up the ability to point copilot code completion requests at
your own local LLM, using e.g.:
- https://github.com/jjleng/copilot-proxy
- https://github.com/bernardo-bruning/ollama-copilot/tree/master

External MITM-proxy tools permitting, this can serve as a stop-gap to
allow local LLM code completion in Zed until a proper OpenAI-compatible
local code completions provider is implemented. With this in mind, in
this PR I've added separate `settings.json` variables to configure a
proxy server _specific to the code completions provider_ instead of
using the global `proxy` setting, to allow for cases like this where we
_only_ want to proxy e.g. the Copilot requests, but not all outgoing
traffic from the application.

Currently, two new settings are added:
- `inline_completions.copilot.proxy`: Proxy server URL (HTTP and HTTPS
schemes supported)
- `inline_completions.copilot.proxy_no_verify`: Whether to disable
certificate verification through the proxy

Example:
```js
"features": {
  "inline_completion_provider": "copilot"
},
"show_completions_on_input": true,
// New:
"inline_completions": {
  "copilot": {
    "proxy": "http://example.com:15432",
    "proxy_no_verify": true
  }
}
```


Release Notes:

- Added the ability to specify an HTTP/HTTPS proxy for Copilot.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-24 12:11:00 -05: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
Cole Miller
1429363218
html: Open extra newline between opening and closing HTML tags (#25130)
Closes #12064

It feels a bit strange to use `brackets` for this but it seems to work
without unintended consequences from my testing so far.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-20 01:09:19 -05:00
Max Brunsfeld
0fdad0c0d6
Use line-based and word-based diff when reloading and formatting buffers (#25129)
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.
2025-02-20 00:56:01 +00:00
Marshall Bowers
d17c6b392e
Add allow_rewrap setting to control editor::Rewrap behavior for a given language (#25173)
This PR adds a new `allow_rewrap` setting to control how
`editor::Rewrap` behaves for a given language.

This is a language setting, so it can either be configured globally or
within the context of an individual language.

For example:

```json
{
  "allow_rewrap": "in_selections",
  "languages": {
    "Typst": {
      "allow_rewrap": "anywhere"
    }
  }
}
```

There are three different values:

- `in_comment`: Only perform rewrapping within comments.
- `in_selections`: Only perform rewrapping within the current
selection(s).
- `anywhere`: Allow rewrapping anywhere.

The global default is `in_comment`, as it is the most conservative
option and allows rewrapping comments without risking breaking other
syntax.

The `Markdown` and `Plain Text` languages default to `anywhere`, which
mirrors the previous behavior for those language that was hard-coded
into the rewrap implementation.

This setting does not have any effect in Vim mode, as Vim mode already
allowed rewrapping anywhere.

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

Release Notes:

- Added an `allow_rewrap` setting to control the `editor::Rewrap`
behavior for a given language.
2025-02-19 16:37:39 +00:00
Conrad Irwin
119bd896b0
Remove language::markdown (#25136)
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
2025-02-19 08:55:36 -07:00
Cole Miller
c0c48d30db
Revert "file_finder: Remove common segments of long paths in search results (#25049)" (#25163)
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
2025-02-19 15:32:29 +00:00
Marshall Bowers
d4b2e88ab8
language: Fix incorrectly-formatted doc comment (#25151)
This PR fixes an incorrectly-formatted doc comment in the
`BufferSnapshot` impl.

Release Notes:

- N/A
2025-02-19 13:09:16 +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
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
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
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
Agus Zubiaga
592e8fbffc
edit predictions: Fix cursor popover edit preview panic (#24866)
Release Notes:

- Fixed a panic when displaying a whitespace-only line in the edit
prediction preview

---------

Co-authored-by: Antonio <antonio@zed.dev>
2025-02-14 15:44:45 +01:00
Piotr Osiewicz
a618830aea
project: Fine-grained language server management (#24038)
Closes #ISSUE
https://github.com/zed-industries/zed/pull/23804
Release Notes:

- Improved detection of project roots for use by language servers.

Closes #ISSUE

Release Notes:

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

---------

Co-authored-by: smit <0xtimsb@gmail.com>
Co-authored-by: Henrikh Kantuni <henrikh.kantuni@gmail.com>
Co-authored-by: Caleb! <48127194+kaf-lamed-beyt@users.noreply.github.com>
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Co-authored-by: Agus Zubiaga <agus@zed.dev>
Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Nate Butler <iamnbutler@gmail.com>
2025-02-14 15:41:49 +01:00
Agus Zubiaga
51092c4e31
Polish edit predictions (#24732)
Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: as-cii <as-cii@zed.dev>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-02-12 15:56:31 +00:00
Marshall Bowers
a2592a3a37
Clean up edit predictions settings (#24692)
This PR does some clean up for the edit predictions settings:

- Removed `editor.show_edit_predictions_in_menu`
- Renamed `edit_predictions.inline_preview` to `edit_predictions.mode`

Release Notes:

- N/A

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
2025-02-11 21:33:31 +00:00
Marshall Bowers
aab3e0495d
inline_completion_button: Add menu option to toggle "Eager Preview"s for edit predictions (#24685)
This PR adds a menu option to the edit prediction menu to toggle the
"Eager Preview" behavior:

<img width="252" alt="Screenshot 2025-02-11 at 2 44 52 PM"
src="https://github.com/user-attachments/assets/232e879b-3c11-4edd-a549-f284e2bca391"
/>

Release Notes:

- N/A
2025-02-11 20:02:52 +00:00
Bennet Bo Fenner
8fa85c41a1
edit prediction: Try to fix panic in Buffer::preview_edits (#24654)
We've seen a few crashes in `SyntaxSnapshot::reparse_with_ranges` during
`Buffer::preview_edits`, where an offset conversion fails because it is
out of range.
We are not sure how exactly this is happening. 
Our theory is that the syntax snapshot is using an outdated state when
edits happen in the meantime (while interpolating). This is an attempt
to see if it helps with the panics, hopefully we can revisit this when
we have a better understanding of the issue.


Co-Authored-by: Antonio <antonio@zed.dev>

Release Notes:

- N/A

Co-authored-by: Antonio <antonio@zed.dev>
2025-02-11 16:35:09 +01:00
Liam Murphy
72e1947025
Update tree-sitter to 0.24 (#24492)
I didn't update it to 0.25 because its Wasm support seems to be
partially broken due to
https://github.com/tree-sitter/tree-sitter/pull/3938: it didn't
introduce a check that the Wasm module's ABI is new enough to include
supertype info while parsing it, and so in the case where it isn't it
ends up interpreting random bytes as the number of supertypes, causing
out-of-bounds memory accesses.

Closes #24489

Release Notes:

- Fixed a rare crash during syntax highlighting
2025-02-10 10:52:27 -08:00
Max Brunsfeld
d9909c691d
Fix panic when outline items have no name (#24574)
Closes #23787

Release Notes:

- Fixed a crash when searching the outline view in certain Ruby files.
2025-02-10 18:50:26 +00:00
Danilo Leal
a7a14e59bf
edit predictions: Clarify disabled_globs documentation (#24460)
This PR clarifies how the `disabled_globs` work.

Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com>
2025-02-07 19:35:55 +01:00
smit
00c2a30059
Migrate keymap and settings + edit predictions rename (#23834)
- [x] snake case keymap properties
- [x] flatten actions
- [x] keymap migration + notfication
- [x] settings migration + notification
- [x] inline completions -> edit predictions 

### future: 
- keymap notification doesn't show up on start up, only on keymap save.
this is existing bug in zed, will be addressed in seperate PR.

Release Notes:

- Added a notification for deprecated settings and keymaps, allowing you
to migrate them with a single click. A backup of your existing keymap
and settings will be created in your home directory.
- Modified some keymap actions and settings for consistency.

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2025-02-07 21:17:07 +05:30
Ben Kunkle
a1544f47ad
Fix incorrect assumption about Path.extension() (#24443)
Release Notes:

- N/A
2025-02-07 09:37:07 -06:00
Ben Kunkle
9c132fece5
Fix #24314 - File icons missing for hidden files (#24391)
- **fix ignoring ignored files when matching icons**
- **remove poorly named and confusing method
`PathExt.icon_stem_or_suffix` and refactor
`PathExt.extension_or_hidden_file_name` to actually do what it says it
does**

Closes #24314

Release Notes:

- Fixed an issue where hidden files would have the default icon instead
of the correct one
- Fixed an issue where files with specific icons (such as
`eslint.config.js`) would not have the their specific icon without a
leading `.` (`.eslint.config.js`)
2025-02-06 14:26:42 -06:00
Agus Zubiaga
e1bb9570df
edit predictions: Reset onboarding action (#24387)
https://github.com/user-attachments/assets/bb597b93-a616-4f8a-8608-013b8202799c


Release Notes:

- N/A
2025-02-06 19:07:27 +00:00
Marshall Bowers
09967ac3d0
zeta: Send up diagnostics with prediction requests (#24384)
This PR makes it so we send up the diagnostic groups as additional data
with the edit prediction request.

We're not yet making use of them, but we are recording them so we can
use them later (e.g., to train the model).

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
2025-02-06 18:07:26 +00:00
Agus Zubiaga
8ed8b4d2ec
edit predictions: Preview while holding modifier mode (#24316)
This PR adds a new `inline_completions.inline_preview` config which can
be set to `auto` (current behavior) or to `when_holding_modifier`.
When set to the latter, instead of showing edit prediction previews
inline in the buffer, we'll show it in a popover (even when there's no
LSP completion) so your isn't constantly moving as completions arrive.


https://github.com/user-attachments/assets/3615d151-3633-4ee4-98b9-66ee0aa735b8

Release Notes:

- N/A

---------

Co-authored-by: Danilo <danilo@zed.dev>
2025-02-06 09:58:19 -03:00
Ben Kunkle
8b3d315e40
Fix #24081 - lsp diagnostic code type conversion (#24347)
- **store `buffer::Diagnostic`as NumberOrString instead of assuming
String**
- **update zed-industries/lsp-types rev**

Closes #24081

Release Notes:

- Fixed an issue where language server diagnostic codes would be converted to strings leading to errors with some language servers
2025-02-05 21:23:46 -06:00
Max Brunsfeld
ca01a8b9cb
Fix two issues with diff highlights (#24309)
* fix syntax highlighting of deleted text when buffer language changes
* do not highlight entire untracked files as created, except in the
project diff view

Release Notes:

- N/A

Co-authored-by: ConradIrwin <conrad.irwin@gmail.com>
Co-authored-by: cole-miller <m@cole-miller.net>
2025-02-05 21:29:39 +00:00
Bennet Bo Fenner
e1a6d9a485
edit prediction: Improve UX around disabled_globs and show_inline_completions (#24207)
Release Notes:

- N/A

---------

Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-02-05 17:09:19 +00:00
Cole Miller
5704b50fb1
git: Compute and synchronize diffs from HEAD (#23626)
This PR builds on #21258 to make it possible to use HEAD as a diff base.
The buffer store is extended to support holding multiple change sets,
and collab gains support for synchronizing the committed text of files
when any collaborator requires it.

Not implemented in this PR:

- Exposing the diff from HEAD to the user
- Decorating the diff from HEAD with information about which hunks are
staged

`test_random_multibuffer` now fails first at `SEED=13277`, similar to
the previous high-water mark, but with various bugs in the multibuffer
logic now shaken out.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Ben <ben@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Conrad <conrad@zed.dev>
2025-02-04 15:29:10 -05:00
Richard Feldman
667396c44b
Use the term "edit prediction" over "inline completion" (#24211)
Note that this does *not* involve any breaking code changes.

cc @0xtimsb - I didn't change any settings or anything here. That can
happen separately!

Release Notes:

- N/A
2025-02-04 10:33:01 -08:00
Conrad Irwin
9a22ef2fd5
Don't save deleted files (#24171)
We now treat new files that have no content as not-dirty. This fixes the
git diff view when deleted files are present.

It also fixes a long-standing bug where `zed RAEDME` and then closing
the tab would prompt for "unsaved changes" when there were none.

Release Notes:

- Fixed a bug where closing an empty, named, file would warn about
unsaved content.
2025-02-03 23:31:34 -07:00
Ben Kunkle
8742c18107
Allow auto-indenting with syntax errors when using regex-based indent matches to improve bash auto-indent behavior (#24160)
- Fixes auto-indent issues around `elif` caused by auto-indent being prevented due to syntax errors generated before `elif` clause completed

Release Notes:

- Fixed an issue where inserting an elif before an else in bash would
not properly auto-indent

---------

Co-authored-by: Conrad Irwin <conrad@zed.dev>
2025-02-03 21:34:37 -06:00
Agus Zubiaga
4c29e1ff07
zeta: Improve UX for simultaneous LSP and prediction completions (#24024)
Release Notes:

- N/A

---------

Co-authored-by: Michael Sloan <michael@zed.dev>
Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Richard <richard@zed.dev>
2025-02-03 21:47:11 -03:00
Bennet Bo Fenner
8edcaec1bf
inline completion: Merge disabled_globs setting with default values (#24122)
This ensures that the following files are always ignored:

```
"**/.env*"
"**/*.pem"
"**/*.key"
"**/*.cert"
"**/*.crt"
"**/secrets.yml"
```

Release Notes:

- N/A
2025-02-03 09:37:46 +00:00
João Marcos
5bd7eaa173
Solve 50+ cargo doc warnings (#24071)
Release Notes:

- N/A
2025-02-01 06:19:29 +00:00
Michael Sloan
17872260e6
Add language::BufferSnapshot::highlighted_text_for_range (#24060)
In support of work on

https://github.com/zed-industries/zed/tree/new-ui-for-edit-prediction-with-lsp-completions,
where we want to be able to extract a range of the buffer as
`HighlightedText`.

Release Notes:

- N/A
2025-01-31 23:36:24 +00:00
Michael Sloan
93c7b54caa
Renames: HighlightedText->HighlightedMatch + HighlightedEdits->HighlightedText (#24057)
In support of work on
https://github.com/zed-industries/zed/tree/new-ui-for-edit-prediction-with-lsp-completions,
where we want to be able to extract a range of the buffer as
`HighlightedText`.

Release Notes:

- N/A
2025-01-31 23:15:46 +00:00
Max Brunsfeld
399e2c1ed3
Revert "project: Fine-grained language server management" (#23977)
Reverts zed-industries/zed#23805
2025-01-30 13:42:56 -08:00
Kirill Bulatov
9e4555797d
Use more LSP data when falling back to regular completions label (#23909)
Closes https://github.com/zed-industries/zed/issues/23590
Closes https://x.com/steeve/status/1865129235536568555

Before:

<img width="773" alt="before"
src="https://github.com/user-attachments/assets/129a8d12-9298-4bf5-8f2d-b3292c2562bf"
/>


After:

<img width="768" alt="after"
src="https://github.com/user-attachments/assets/e0516fb3-b02a-48be-8923-63bba05fdb69"
/>


The list obviously needs some solution for the cut-off part of the
completion label, but this is the reality for all extensions'
completions too, so one step at a time.


Release Notes:

- Improved default completion label fallback
2025-01-30 15:05:34 +00:00
Bennet Bo Fenner
5e449c84fe
edit prediction: Add syntax highlighting for diff popover (#23899)
Co-Authored-by: Antonio <antonio@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
2025-01-30 11:53:51 +01:00