Commit Graph

7160 Commits

Author SHA1 Message Date
Kirill Bulatov
7ac1885449 Properly refresh hints on editor open 2023-06-29 22:25:49 +03:00
Kirill Bulatov
58343563ba Fix hint querying bugs 2023-06-29 22:25:49 +03:00
Kirill Bulatov
debdc3603e Finish rest of the inlay cache logic 2023-06-29 22:25:49 +03:00
Kirill Bulatov
ddcbc73bf0 Implement inlay hint replaces for conflict-less case 2023-06-29 22:25:49 +03:00
Kirill Bulatov
6368cf1a27 Merge excerpt-related hint data, move next_inlay_id into Editor 2023-06-29 22:25:49 +03:00
Kirill Bulatov
8c03e9e122 Move InlayId generation back to InlayCache 2023-06-29 22:25:49 +03:00
Kirill Bulatov
e82b4d8957 Properly handle hint addition queries 2023-06-29 22:25:49 +03:00
Kirill Bulatov
5322aa09b9 Properly handle settings toggle 2023-06-29 22:25:49 +03:00
Kirill Bulatov
8f68688a64 Allow readding inlays with existing ids, move inlay types 2023-06-29 22:25:49 +03:00
Kirill Bulatov
49c00fd571 Generate InlayIds in InlayMap, prepare InlayCache for refactoring 2023-06-29 22:25:49 +03:00
Kirill Bulatov
e217a95fcc Cleanup the warnings 2023-06-29 22:25:49 +03:00
Kirill Bulatov
76d35b7122 Use proper, limited excerpt ranges and manage inlay cache properly 2023-06-29 22:25:49 +03:00
Kirill Bulatov
2b989a9f12 Fix all the tests
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
d4d88252c3 Fix most of the FoldMap random tests with inlays
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
f2c510000b Fix all FoldMap tests (without real inlays inside)
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
29bb6c67b0 Fix first FoldMap methods after the map move
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
9ae611fa89 Fix InlayMap bugs after the map order revers
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
05dc672c2a Apply questionable changes to make things compile 2023-06-29 22:25:49 +03:00
Kirill Bulatov
10765d69f4 Move inlay map to be the first one
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
e744fb8842 Avoid having carriage returns (\r) in inlays
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
d2fef07782 Remove the SuggestionMap
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
8cdf1a0faf Switch over to inlay map for Copilot suggestions
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Antonio Scandurra
89137e2e83 Fix InlayMap::buffer_rows 2023-06-29 22:25:49 +03:00
Kirill Bulatov
34c6d66d04 Implement InlayBufferRows properly
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
bec9c26fa2 Fix more inlay_map corner cases and hangings
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
02e124cec4 Fix inlay map tests
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
b231fa47af Apply hints setings on startup 2023-06-29 22:25:49 +03:00
Kirill Bulatov
c898298c5c Properly update inlay hints when settings are changed 2023-06-29 22:25:49 +03:00
Kirill Bulatov
1ed52276e0 Add inlay hint settings 2023-06-29 22:25:49 +03:00
Kirill Bulatov
ea837a183b Store inlays per paths and query on editor open 2023-06-29 22:25:49 +03:00
Kirill Bulatov
8acc5cf8f4 Deserialize more LSP inlay hint information 2023-06-29 22:25:49 +03:00
Kirill Bulatov
f155f5ded7 Better rpc inlay hint handling 2023-06-29 22:25:49 +03:00
Kirill Bulatov
b3aa75a363 Refresh inlays on buffer reopens 2023-06-29 22:25:49 +03:00
Kirill Bulatov
e1f22c3684 Cache anchors from all versions, remove out of range hints 2023-06-29 22:25:49 +03:00
Kirill Bulatov
7abaf22b93 Generate proper inlay diffs for splice 2023-06-29 22:25:49 +03:00
Kirill Bulatov
6d1068d1e9 Query inlay hints for excerpt ranges only 2023-06-29 22:25:49 +03:00
Kirill Bulatov
271cd25a1d Display excerpt-ranged hints only 2023-06-29 22:25:49 +03:00
Kirill Bulatov
addb62c1fc Fix the duplicate hints
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
63074c5cd8 Better bias selection for hints that prefix the type
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Antonio Scandurra
2b1b1225f5 Simplify InlayMap::splice interface 2023-06-29 22:25:49 +03:00
Antonio Scandurra
7684a26daa Fix point/offset translation and clipping in the InlayMap
This makes all randomized tests pass. We're only missing `buffer_rows`
now and we should move the map right above `MultiBuffer` and below `FoldMap`.
2023-06-29 22:25:49 +03:00
Kirill Bulatov
c7fa8dbc70 React with inlay updates on excerpt events 2023-06-29 22:25:49 +03:00
Kirill Bulatov
df20a43704 Reuse the copilot suggestion style for inlays 2023-06-29 22:25:49 +03:00
Kirill Bulatov
8a64b07622 Fixed inlay hints' edits generation and moved on with the randomized
test

Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Antonio Scandurra
e280483c5f Make the randomized tests pass
Right now we only check that the text is correct, but I think
we're getting there.
2023-06-29 22:25:49 +03:00
Kirill Bulatov
afa59eed01 Fix the randomized tests
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
f940104b6f Add inlay hint randomization in the text
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
dbd4b33568 Fix splice edits generation
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
9ce9b73879 Generate edits for inlay hints
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
f5f495831a Add inlay hints randomized test, fix the errors
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
2e730d8fa4 Implement initial changes reporting for inlay hints
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
4d76162da8 Report the edits per transform summary generated
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
2ba3262f29 Add line_len snapshot method
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
ab7dd80423 Add more InlaySnapshot text summary impls
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
568a67c4d7 Implement more InlaySnapshot methods
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov
daa2ebb57f Calculate anchors for new hints 2023-06-29 22:25:49 +03:00
Kirill Bulatov
5fadbf77d4 Implement InlayHint sync method and fix the bugs
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:48 +03:00
Kirill Bulatov
5ad85b44d6 Implement chunks of the InlayMap
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:48 +03:00
Kirill Bulatov
3028767d12 Improve on inlya locations 2023-06-29 22:25:48 +03:00
Kirill Bulatov
b193d62a5d Initial InlayMap tests and splice fn impl
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:48 +03:00
Kirill Bulatov
7397b8028c Simplify inlay hint version handling 2023-06-29 22:25:48 +03:00
Kirill Bulatov
d506522eef Correctly pass inlay hints 2023-06-29 22:25:48 +03:00
Kirill Bulatov
b5233b3ad5 Rename the new map 2023-06-29 22:25:48 +03:00
Kirill Bulatov
9287634548 Prepare to find diffs between inlay hint generations 2023-06-29 22:25:48 +03:00
Kirill Bulatov
78b3c9b88a Store hints in the new map only 2023-06-29 22:25:48 +03:00
Kirill Bulatov
83f4320b60 Replace todo!s with stub calls to make Zed work 2023-06-29 22:25:48 +03:00
Kirill Bulatov
4c3c0eb796 Draft the hint render data flow 2023-06-29 22:25:48 +03:00
Kirill Bulatov
2ead3de7de Add basic infrastructure for inlay hints map 2023-06-29 22:25:48 +03:00
Kirill Bulatov
6e3d1b962a Draft the initial protobuf changes 2023-06-29 22:25:48 +03:00
Kirill Bulatov
387415eb01 Request hints for all buffers in editor 2023-06-29 22:25:48 +03:00
Kirill Bulatov
f83cfda9bc React on message-less LSP requests properly
Co-Authored-By: Julia Risley <julia@zed.dev>
2023-06-29 22:25:48 +03:00
Kirill Bulatov
7a268b1cf6 Improve obvious faults 2023-06-29 22:25:48 +03:00
Kirill Bulatov
79b97f9e75 Stub initial hint requests 2023-06-29 22:25:48 +03:00
Kirill Bulatov
8a3b515f56 Initial protocol check commit 2023-06-29 22:25:48 +03:00
Max Brunsfeld
922d8f30d6 Tweak debug log message when ignoring fs events 2023-06-29 12:01:59 -07:00
Max Brunsfeld
8609ccdcf7 Add test coverage for FS events happening inside unloaded dirs 2023-06-29 11:55:25 -07:00
Max Brunsfeld
ba80c53278 Avoid redundant FS scans when LSPs changed watched files
* Don't scan directories if they were already loaded.
* Do less work when FS events occur inside unloaded directories.
2023-06-29 11:35:49 -07:00
Julia
2ed0284d49 Stub out for language plugin 2023-06-28 17:06:50 -04:00
Julia
48bed2ee03
Merge branch 'main' into fix-broken-lsp-installations 2023-06-28 16:46:06 -04:00
Julia
db2b3e47bc Reinstall Node whenever a NodeRuntime operation has serious error 2023-06-28 16:43:45 -04:00
Joseph T. Lyons
6c53653831 v0.94.x dev 2023-06-28 12:23:42 -04:00
Mikayla Maki
ce52d90a9d
Collab UI v2 (#2618)
This PR implements
https://www.figma.com/file/pLq7dvhx2mFeWFOedXpUQ5/Project-%E2%80%93-Collaboration-UI?type=design&node-id=666%3A8610&t=XFGk6KEtTCFXBvCQ-1

Release notes:
- [x] Redesigned collaboration UI
- [x] Added voice support
2023-06-28 09:14:39 -07:00
Mikayla Maki
cb782c5a7b
Remove menu tracking state 2023-06-28 09:06:06 -07:00
Max Brunsfeld
34b81e2aab collab 0.15.0 2023-06-28 09:01:07 -07:00
Mikayla Maki
88b30dea10
fmt 2023-06-28 08:44:17 -07:00
Mikayla Maki
9ab0efa1f8
Fix microphone and speaking styles 2023-06-28 08:41:31 -07:00
Julia
1882ce48be Handle new elixir-ls release zip name 2023-06-28 10:22:39 -04:00
Piotr Osiewicz
49ce1977e3 Optimize user menu trigger 2023-06-28 15:27:38 +02:00
Piotr Osiewicz
c2f5855fdc Fix warning 2023-06-28 15:22:17 +02:00
Piotr Osiewicz
456be1f86e Hide user menu on second click 2023-06-28 15:19:32 +02:00
Antonio Scandurra
2cb4616609 Enable assistant on stable
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2023-06-28 12:09:49 +02:00
Nathan Sobo
8f8a99d788 Bind cmd-? to assistant::toggle_focus
Bypass system help menu shortcut at the app delegate level to achieve this.

Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-28 11:43:24 +02:00
Piotr Osiewicz
2ddf0e12bf Undeafen: unmute if user was not muted prior to deafening 2023-06-28 11:10:56 +02:00
Nathan Sobo
83fc7b9b7c Avoid scrolling to the new cursor position so the assistant's output is stable
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-28 10:32:06 +02:00
Nathan Sobo
f52d3ea5ef Clean up tooltips, create conversation on cmd-n
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-28 10:27:29 +02:00
Mikayla Maki
749f60ba81
fmt 2023-06-27 19:25:46 -07:00
Mikayla Maki
5d02b49058
Added muted and currently speaking tracking 2023-06-27 19:23:13 -07:00
Max Brunsfeld
f128cf4a33
Defer scanning some worktree subdirectories until they are expanded in the project panel (#2622)
Closes
https://linear.app/zed-industries/issue/Z-352/high-memory-usage-from-fs-scanning-if-project-contains-symlinks-that

### Background

Currently, when you open a project, Zed eagerly scans the directory,
building an in-memory representation of all of the files and directories
within. This scanning includes all git-ignored files and follows any
symlinks. When any directory changes on disk, Zed recursively rescans it
in order to keep its in-memory representation up-to-date. When
collaborating, all of these files are replicated to all guests.

Right now, there are some performance problems associated with the
maintenance of this filesystem state:
* For various reasons, some projects contain symlinks that point out to
large folders like `$HOME`, which itself contains many symlinks that
point to the same large directory. When these projects are opened, the
worktree scans endlessly, using more and more memory.
* Some git-ignored directories (like `target` in a rust project) contain
*many* more files than are actually tracked in the git repository. These
files often change as a result of saving, (e.g. because the compiler
runs). Maintaining in memory all of these paths isn't useful to the
user, and causes significant CPU usage on every save. Most importantly,
when collaborating sending all of these changes to guests can be slow,
and can delay all other RPC messages.

### Change

This PR changes the worktree's filesystem-scanning logic to be *lazy*
about scanning two types of directories:
* git ignored directories
* "external" directories (those that are canonically located outside of
the worktree root, but accessed via symlinks)

The laziness works as follows. When, during a recursive scan, a
directory is found that falls into one of the above 2 categories, that
directory is marked as "unloaded". The directory might later be scanned,
if some explicit operation is performed within it (like opening a
buffer, or creating a file), if any collaborator expands that directory
in their project panel, or if an LSP requests that it be watched.

### Results

When collaborating on the `zed` folder:

| metric | before | after |
|-------|--------|------|
| # `worktree_entries` in collab db initially | 154,763 |  77,679 |
| # `worktree_entries` in collab db after 5 saves | 181,952 | 77,679
(nothing new to scan) |
| app memory footprint (host) | 260MB | 228.5 MB  |

The db thing is a win, because reading and writing to the
`worktree_entries` table is one of the most expensive thing that the
`collab` server does.

There's also generally lower background CPU usage after every save,
because we don't need to recursively rescan directories inside of
`target`.

### Limitations

We still end up scanning some unnecessary directories (like
`target/debug/build/zed-b612db829aeac16e/out`) because the LSP instructs
us to watch those.

### To do:

* [x] Expand parent directories of any path opened via LSP
* [x] Avoid creating orphaned entries when FS events happen inside of
unscanned directories
* [x] Scan any newly-non-ignored directories after gitignore changes
* [x] Emit correct events for newly-discovered paths when expanding dirs
* [x] GC the set of expanded directory ids when dirs are removed
* [x] Don't include "external" entries in file-finder
* [x] Expand any directories watched by LSP
* [ ] manual testing and profiling

### Release Notes:

- Fixed a bug where Zed would use excessive memory when a project folder
contained symlinks pointing to directories outside of the project.
- Reduced Zed's memory and CPU usage when working in folders containing
many git-ignored files.
2023-06-27 17:07:23 -07:00
Max Brunsfeld
201188fdaa Use FakeFs in worktree gitignore test 2023-06-27 15:40:36 -07:00
Max Brunsfeld
fc02381196
Fix bugs in handling combined injections exposed by HEEx (#2652)
Fixes
https://linear.app/zed-industries/issue/Z-2481/heex-this-snippet-triggers-a-hard-crash

Release Notes:

- Fixed a crash that would sometimes occur when editing a HEEx file
([#1703](https://github.com/zed-industries/community/issues/1703)).
2023-06-27 15:17:29 -07:00