Commit Graph

678 Commits

Author SHA1 Message Date
Keith Simmons
a477733bcb Address hover panic and add hint to install go when language server failed to install 2022-06-27 15:48:15 -07:00
Keith Simmons
bc82d98ae5
Merge pull request #1237 from zed-industries/jump-to-definition
Mouse jump to definition
2022-06-27 15:20:07 -07:00
Antonio Scandurra
7bfd7093b1 Don't stop scanning directory if reading one of the children errors 2022-06-27 08:40:37 +02:00
Keith Simmons
92ab107fc9 working jump to definition with tests 2022-06-24 15:09:31 -07:00
Keith Simmons
848445455d Working underline based on symbol origin 2022-06-24 15:05:35 -07:00
Keith Simmons
755636d10e Use NonZeroU32 to ensure settings tabsize cannot be zero 2022-06-23 12:55:38 -07:00
Antonio Scandurra
2cb8a3ccfb Don't override top-level settings with language defaults
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-06-23 16:40:57 +02:00
Antonio Scandurra
2d8ffbdfa2 Don't wait for host's worktree updates if they disconnected
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-22 19:45:55 +02:00
Antonio Scandurra
2f09a4af16 Update project metadata when releasing a worktree's weak handle
When a project was getting unshared, we would remove invisible worktrees
from the project's state without notifying the server, which was causing
the randomized tests to fail.

This commit calls `Project::remove_worktree` when a worktree's handle gets
released. Doing so ensures that we update both our local metadata database
as well as the state on the server.
2022-06-22 10:26:10 +02:00
Antonio Scandurra
69aa3d848e Report running language servers when sharing project for the first time
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-21 20:39:54 +02:00
Antonio Scandurra
4f215a77cd Don't compute fingerprint for every text summary 2022-06-17 15:15:27 +02:00
Antonio Scandurra
6f7a893ec9 Determine Buffer::is_dirty based on the rope's fingerprint 2022-06-17 12:38:25 +02:00
Antonio Scandurra
dc75b70724 Use word boundaries instead of syntax to infer completion edit ranges 2022-06-16 11:27:22 +02:00
Antonio Scandurra
35889add40 Add failing test for wrong typescript completion 2022-06-16 11:26:35 +02:00
Antonio Scandurra
3a1d0dd692 Track active projects in metrics
An active project is defined as a project where there has been at
least a buffer edit, a join request/response, or a follow update
in the last minute.
2022-06-15 10:33:20 +02:00
Keith Simmons
93158bfcff Fix delayed lsp request 2022-06-09 17:03:45 -07:00
Max Brunsfeld
87ba68e3ea
Merge pull request #1155 from zed-industries/golang
Add Go support
2022-06-09 14:18:37 -07:00
Max Brunsfeld
4ce4c0ef03 Ignore completions from gopls that we can't yet handle
We only support additionalEdits if they are provided when resolving the
completion, not if they are provided immediately.
2022-06-09 13:08:08 -07:00
Antonio Scandurra
213b31607c Remove language server statuses synchronously when stopping a server 2022-06-09 10:59:02 +02:00
Antonio Scandurra
69170fc33a Add unit test to ensure changing enable_language_server works 2022-06-09 10:48:06 +02:00
Antonio Scandurra
36a1a7a819 Start/stop language servers when enable_language_server changes 2022-06-09 10:08:11 +02:00
Antonio Scandurra
9d7476afc6 Extract a Project::stop_language_server method when restarting server
This will be useful later to stop a language server when detecting
configuration changes.
2022-06-09 10:05:35 +02:00
Max Brunsfeld
36ce3eb5ef Handle messages associated with LSP WorkDoneProgress::Begin messages
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-08 10:26:41 -07:00
Antonio Scandurra
eda569d6b2 Snapshot file instead of path when creating a buffer snapshot 2022-06-08 14:29:14 +02:00
Antonio Scandurra
d8b885e3ec Provide tab_size when formatting document using LSP range formatting 2022-06-08 09:56:11 +02:00
Keith Simmons
9d5111e86a
Merge pull request #1078 from zed-industries/lsp-hover
LSP Hover Information
2022-06-07 14:45:43 -07:00
Keith Simmons
1b66e1e185 Add integration test and fix hovering over the wire 2022-06-07 14:22:02 -07:00
Keith Simmons
a6c0ee472c Add vim bindings for hover
Allow scrolling in hover popover
2022-06-07 13:07:53 -07:00
Keith Simmons
67d9abc00f Move highlighting to editor code and implement proto message types for hover response 2022-06-07 11:54:52 -07:00
Keith Simmons
c7cc07aafb working markdown rendering 2022-06-07 11:54:51 -07:00
Keith Simmons
b014352740 Syntax highlighting working. Getting started on markdown support 2022-06-07 11:54:33 -07:00
Isaac Clayton
d529a1deb4 Add basic debounce, fix flickering 2022-06-07 11:54:31 -07:00
Keith Simmons
560dff7329 Pull hover popover out of context menu 2022-06-07 11:54:00 -07:00
Isaac Clayton
470c70d394 Get minimal POC working 2022-06-07 11:52:52 -07:00
Antonio Scandurra
b04e62d895 Fix tracking of in-progress disk-based diagnostics on indicator
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-07 19:35:53 +02:00
Antonio Scandurra
bbfa6580a4 Avoid refreshing diagnostics for language servers that didn't update
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-06-07 19:05:06 +02:00
Antonio Scandurra
1ecc51f035 Fix warnings 2022-06-06 16:23:49 +02:00
Antonio Scandurra
70afc06666 Handle out-of-order edits coming from LSP 2022-06-06 16:15:11 +02:00
Max Brunsfeld
ed14fd6e0d Add setting to make projects online/offline by default 2022-06-03 17:01:15 -07:00
Max Brunsfeld
24aafde1e8 Avoid persisting project's state before it has been initialized 2022-06-03 16:40:16 -07:00
Max Brunsfeld
e18bc24989 Rename project's 'public'/'private' flag to 'online'/'offline' 2022-06-03 14:39:06 -07:00
Max Brunsfeld
afdd386057 Move persistence and restoration logic from workspace into project
Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-06-03 11:52:14 -07:00
Max Brunsfeld
36a4d31b5b Keep unregistered projects' ids until pending contact updates are done 2022-06-02 18:04:54 -07:00
Max Brunsfeld
f7e7a7c6a7 Use rocksdb to store project paths' public/private state 2022-06-02 17:38:33 -07:00
Max Brunsfeld
d45db1718e Style the contact panel while public/private operations are in-flight 2022-06-02 17:38:33 -07:00
Max Brunsfeld
d11beb3c02 Change project registration RPC APIs to smooth out UI updates
* Make `UnregisterProject` a request. This way the client-side project can wait
  to clear out its remote id until the request has completed, so that the
  contacts panel can avoid showing duplicate private/public projects in the
  brief time after unregistering a project, before the next UpdateCollaborators
  message is received.
* Remove the `RegisterWorktree` and `UnregisterWorktree` methods and replace
  them with a single `UpdateProject` method that idempotently updates the
  Project's list of worktrees.
2022-06-02 17:32:43 -07:00
Max Brunsfeld
3ea061a11e Allow making projects private 2022-06-02 17:32:42 -07:00
Max Brunsfeld
7ef9de32b1 Show private projects in the contacts panel
Introduce a ProjectStore that lets you iterate through all open projects.
Allow projects to be made public by clicking the lock.
2022-06-02 17:29:11 -07:00
Max Brunsfeld
a60fef52c4 Start work on private projects 2022-06-02 17:29:11 -07:00
Antonio Scandurra
6baf8b033b Don't reuse the same diagnostic group id across buffers
This lets us use the group id as the key for an `ElementState`, which
fixes a panic that would occur in project diagnostics when opening it
while there were multiple diagnostic groups with the same id.
2022-06-02 12:05:28 +02:00
Max Brunsfeld
b9dc476e74 Avoid sending unnecessary messages for local projects that aren't shared 2022-06-01 14:49:12 -07:00
Antonio Scandurra
339069b1d3 Cap MessageStream buffer size to 1MB
We temporarily let it grow when the message size exceed the limit,
but restore the buffer's capacity shortly after. This ensures that,
for each connection in its entire lifetime, we only ever use 1MB.
2022-05-31 11:16:32 +02:00
Antonio Scandurra
354488ebdf Don't eagerly populate copied subdirectory
This can race anyway with snapshot updates, so we just eagerly refresh
the root entry and wait for updates to come in to populate it.
2022-05-31 08:11:07 +02:00
Antonio Scandurra
20e1044d49 Merge branch 'main' into project-panel-with-new-mouse-events 2022-05-30 18:29:46 +02:00
Antonio Scandurra
88fdd8606a Eagerly populate child entries when copying a directory via RPC 2022-05-30 18:01:46 +02:00
Antonio Scandurra
3336bc6ab3 Implement copy paste for ProjectPanel 2022-05-30 14:52:34 +02:00
Max Brunsfeld
e6be151a64 Emit the WorktreeRemoved event when removing a worktree from a project 2022-05-27 10:49:10 -07:00
Max Brunsfeld
a1a4c70845 Emit an event when adding a worktree to a project 2022-05-27 10:48:47 -07:00
Antonio Scandurra
3ac6fc89c1 Pretty-print JSON of server snapshot 2022-05-26 09:34:39 +02:00
Antonio Scandurra
ec88288d5e Bump chunk size to 256 2022-05-24 09:54:53 +02:00
Antonio Scandurra
85f228dade Fix logic error when streaming ignored entries
We were calling `next` twice, which led us to skip every other entry.
This commit also enhances the `test_share_project` integration test
to exercise this new streaming logic.
2022-05-24 09:03:05 +02:00
Antonio Scandurra
94e70bc1a6 WIP: log received updated_entries on remote worktree
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-23 19:39:24 +02:00
Antonio Scandurra
c65dae8095 Correctly assign ignored status in refresh_entry
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-23 19:19:13 +02:00
Antonio Scandurra
23ca9dce2e WIP: stream ignored entries 2022-05-23 16:38:16 +02:00
Antonio Scandurra
fe1498dc1d Fix worktree::Snapshot::entries(true) always being empty 2022-05-23 15:38:20 +02:00
Max Brunsfeld
ef0b584532 Remove AppState from workspace actions
This allows those actions to be bound to keystrokes in the keymap.
Also, remove the WorkspaceParams struct, simplify how Workspaces are
constructed.
2022-05-19 14:37:26 -07:00
Antonio Scandurra
7b161b81b5 WIP: accept to join requests if user is already participating
There's a panic caused by `Store::check_invariants` that we still
need to figure out.
2022-05-17 13:21:20 +02:00
Nathan Sobo
d821e7a4c1 Cancel join requests when the requester closes the window 2022-05-16 20:29:36 -06:00
Antonio Scandurra
ed6ed99d8f Show the reason why a join request was declined
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-16 19:57:50 +02:00
Antonio Scandurra
47ce8ae05c Poll snapshot after refreshing entry 2022-05-16 11:50:21 +02:00
Antonio Scandurra
b144995f27 Grab share state after retrieving metadata when refreshing entry 2022-05-16 11:46:49 +02:00
Max Brunsfeld
842bfae3af WIP - update worktree's scan_id when mutating it in the foreground 2022-05-13 17:03:48 -07:00
Antonio Scandurra
5789aeea24 Fix randomized test failure caused by unsharing while guest was joining
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-13 17:39:13 +02:00
Antonio Scandurra
dd684d26a1 Make Project::share and Project::unshare private
This is still in-progress because randomized tests are failing.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-13 17:17:20 +02:00
Max Brunsfeld
be51a58311 Start work on requesting to join projects
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-12 17:53:11 -07:00
Max Brunsfeld
3dee656490 Avoid panic when language server is dropped before being initialized in tests
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-09 18:05:10 -07:00
Max Brunsfeld
054d697fb7 Remove remaining code associated with .zed.toml files 2022-05-09 16:31:30 -07:00
Max Brunsfeld
2aec4ff234 Pick files directly from the Fs in simulate_host
Previously, the list of all existing files was maintained separately, but
it was not updated when a guest created a file.
2022-05-09 15:39:45 -07:00
Max Brunsfeld
ea81737a88 Allow fuzzy-search for potential contacts in the contacts panel
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-05 14:14:44 -07:00
Antonio Scandurra
6212f2fe30 Wait for remote worktree to catch up with host before mutating entries
This ensures that entries don't randomly re-appear on remote worktrees
due to observing an update too late. In fact, it ensures that the remote
worktree has the same starting state of the host before preemptively applying
the fs operation locally.
2022-05-05 13:47:53 +02:00
Antonio Scandurra
ecb847a027 Fix bugs in FakeFs::{remove_dir,rename} 2022-05-05 09:02:31 +02:00
Max Brunsfeld
4b1c46fa45 Allow deleting entries from the project panel 2022-05-04 18:00:23 -07:00
Max Brunsfeld
509ede0e80 Allow guests to create directories 2022-05-04 16:52:46 -07:00
Max Brunsfeld
40e0f10195 Allow creating directories from the project panel 2022-05-04 16:47:11 -07:00
Max Brunsfeld
a2c22a5e43 Prevent eager snapshot mutations from being clobbered by background updates
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-04 15:10:39 -07:00
Max Brunsfeld
438e4e7a19 Allow guests to rename stuff
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-05-04 10:28:44 -07:00
Nathan Sobo
470d693d5e Rename entries via the project to prepare for guest support
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-05-04 10:28:44 -07:00
Max Brunsfeld
657ea264cc Allow guests to create files from the project panel
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-05-04 10:28:44 -07:00
Max Brunsfeld
8291b8108d Update snapshot atomically when processing FS events 2022-05-04 10:28:44 -07:00
Max Brunsfeld
0ff39f1280 Select new files in the project panel after creating them 2022-05-04 10:28:44 -07:00
Max Brunsfeld
a19766931d Rename entry atomically in LocalWorktree::rename 2022-05-04 10:28:44 -07:00
Max Brunsfeld
8fdc5c9be3 Improve the appearance of project panel filename editor
* Always layout single-line editors with a fixed height
* Preserve directory chevron when editing folder names
* Allow theming the filename editor

Co-authored-by: Antonio Scandurra <me@as-cii.com>
2022-05-04 10:28:44 -07:00
Max Brunsfeld
333b4aaf4e Implement Rename command in project panel 2022-05-04 10:28:09 -07:00
Max Brunsfeld
a217e2e64b Implement basic AddFile command in project panel 2022-05-04 10:28:09 -07:00
Max Brunsfeld
d4492086b3 Abstract more local project setup inside Project::test helper 2022-05-04 10:28:09 -07:00
Keith Simmons
d4bef67cf2
Merge pull request #929 from zed-industries/non-uniform-batched-edits
Allow batched edits where each range is associated with different insertion text
2022-04-29 16:14:38 -07:00
Keith Simmons
b4b61b4bbc Consolidate edit and edit_batched functions 2022-04-28 16:52:04 -07:00
Keith Simmons
04fc1d5982 Building, but failing test WIP 2022-04-27 17:25:38 -07:00
Antonio Scandurra
c955645bc0 Update share icon and swap its posiiton 2022-04-26 14:35:13 +02:00
Max Brunsfeld
45922603f8 Infer completions old ranges based on the syntax tree 2022-04-25 13:14:05 -07:00
Max Brunsfeld
8ddc7e6458 Respect lsp completions' 'insert_text' property when present
Fixes #839
2022-04-22 14:33:13 -07:00
Antonio Scandurra
63cdf61c53 Fix Project::test_rename 2022-04-22 15:59:20 +02:00
Antonio Scandurra
f91fdd2ba0 Return None when prepare rename is not available on language server 2022-04-22 15:43:23 +02:00
Max Brunsfeld
f52050a9ec Use the 'jsonc' language id for all JSON files
This way, comments are allowed by the language server.
2022-04-21 12:08:16 -07:00
Antonio Scandurra
8ef6b1d8a9 Don't emit event when LSP reports consecutive empty diagnostics
This is related to #849: in that pull request we avoided *storing*
empty diagnostics, but we'd still report an event when receiving
consecutive empty diagnostics. So if the project diagnostics editor
was open, it could happen that opening a buffer would cause the
language server to report zero diagnostics. We would therefore close
the buffer because there were no diagnostics, but doing so would cause
the LSP to report another event with zero diagnostics. This would repeat
forever, causing Zed to use a lot of CPU and the UI not to refresh properly.

With this commit we will simply avoid emitting a `DiagnosticsUpdated` event
altogether if no diagnostics were present before *and* the LSP is reporting
a `PublishDiagnostics` event with no diagnostics in it.
2022-04-20 15:02:38 +02:00
Antonio Scandurra
ef784cf21e Remove summaries that don't contain any errors or warnings
When opening a buffer, some language servers might start reporting
diagnostics. When closing a buffer, they might report that no diagnostics
are present for that buffer. Previously, we would keep an empty summary entry
which would cause us to open a buffer in the project diagnostics view, only to
drop it because it contained no diagnostics. However, the act of opening it
caused the language server to asynchronously report non-empty diagnostics.
We would therefore handle this as an update, but the previous closing of the
buffer would cause the language server to report empty diagnostics again. This
would cause the project diagnostics view to thrash infinitely between these two
states, pegging the CPU and constantly refreshing the UI.

With this commit we won't maintain empty summary entries for files that contain
no diagnostics, which fixes the above issue.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-19 15:30:46 +02:00
Antonio Scandurra
eaa6637b05 Use the entire ProjectPath to find open buffer for an LSP diagnostic
Previously, we would only compare the path relative to the worktree root, which
would cause Zed to sometimes update diagnostics on the wrong buffer. This
manifested in the project diagnostics not showing those errors/warnings while
the status bar and the tab title displayed a summary with errors/warnings.

This commit simply uses `Project::get_open_buffer` which correctly locates a
buffer with the given project path.
2022-04-19 12:06:14 +02:00
Max Brunsfeld
6317c049c5
Merge pull request #800 from zed-industries/tolerate-lsp-workspace-symbols-failure
Avoid bailing out of Project::symbols when one LSP request fails
2022-04-11 21:14:51 -07:00
Max Brunsfeld
ae9f71cc07 Avoid bailing out of Project::symbols when one LSP request fails 2022-04-11 21:09:01 -07:00
Max Brunsfeld
949fbe7cd3 Allow dumping the project diagnostic view's state as JSON
Also, improve DebugElements action so that it shows the JSON in an editor.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-04-11 19:51:46 -07:00
Nathan Sobo
17195e615e
Merge pull request #781 from zed-industries/structured-logging
Introduce structured logging
2022-04-09 07:40:24 -06:00
Nathan Sobo
7e5a3f9f6b Introduce structured logging
We're enabling the log crate feature everywhere, but only using it on the server for now.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-08 10:06:51 -06:00
Antonio Scandurra
c994263225 Don't insert an empty vector in Project::buffer_snapshots
Other code paths rely on at least a version always being there, so
we should enforce that invariant everywhere.
2022-04-08 14:14:45 +02:00
Antonio Scandurra
663beab1b9 Avoid panicking when receiving a request for a dropped buffer 2022-04-08 12:10:45 +02:00
Antonio Scandurra
3daaef02ca Replace postage::oneshot with futures::channel::oneshot
This fixes an error in the randomized test that would cause the future
returned from `Worktree::share` to never finish due to a bug in `postage`
that causes its waker to not be notified upon drop.
2022-04-08 12:03:09 +02:00
Max Brunsfeld
f73de202d0 Fix diagnostic updates after restarting an LSP w/ a pending diagnostic job 2022-04-06 22:02:27 -07:00
Max Brunsfeld
8f38ac8270 Tweak structure of Project::on_lsp_progress so it can be auto-formatted
Previously, rustfmt seems to have given up on formatting this method.
2022-04-06 16:35:58 -07:00
Keith Simmons
1812480cbb Tab size is pulled properly from settings instead of hardcoded 2022-04-06 10:23:37 -07:00
Antonio Scandurra
cc45658b2d Clear diagnostics from buffer when unregistering it from language server
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-04-05 16:01:33 +02:00
Antonio Scandurra
5c7f2bb029 Close and re-open buffer in language server when it gets renamed 2022-04-05 15:15:43 +02:00
Antonio Scandurra
9188f51993 Add unit test to illustrate how language server renames should work 2022-04-05 14:47:37 +02:00
Max Brunsfeld
fe27a27cb6 Merge branch 'main' into prompt-on-close 2022-04-01 15:29:23 -07:00
Max Brunsfeld
6f28033efe Add explanatory comments in unit test for code actions w/ commands 2022-04-01 13:00:06 -07:00
Max Brunsfeld
fe8e06e781 Fix clipping when using label-only completions 2022-04-01 12:07:41 -07:00
Max Brunsfeld
ba009724dd Handle LSP apply workspace edit request fully before responding 2022-04-01 11:59:21 -07:00
Max Brunsfeld
56523b5775 Allow applying code actions that use commands
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-04-01 10:16:26 -07:00
Antonio Scandurra
65048760b2 Allow explicit reload of buffers via Project::reload_buffers 2022-04-01 14:01:56 +02:00
Max Brunsfeld
fed5d141bc Start work on applying code actions that use commands
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-31 22:03:52 -07:00
Max Brunsfeld
e987a8ba63 Let fake and real LanguageServer access AsyncAppContext in handler callbacks
Also, reimplement FakeLanguageServer by wrapping LanguageServer, instead of
duplicating its functionality differently.
2022-03-31 21:57:00 -07:00
Keith Simmons
afbddc1bcd Address panic when completions requested and returned to outdated buffer 2022-03-31 18:22:55 -07:00
Keith Simmons
564225c401 Provide diagnostic context to codeAction
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-31 15:39:52 -07:00
Keith Simmons
9385690b98 Add test for common_prefix_at and rewrite it to be more readable and
pass the new test cases
2022-03-31 01:09:58 -07:00
Max Brunsfeld
263e3d8176 Start work on interpreting 'label/insertText' completions
These completions don't supply a range that should be overwritten, so
the client needs to infer it via substring matching.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-03-30 17:47:25 -07:00
Max Brunsfeld
c280c85ce7 Hard-code LSP formatting options for now
This is needed for auto-formatting to work properly in TypeScript and JSON

Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-30 17:08:40 -07:00
Max Brunsfeld
4805cfe48c Merge branch 'main' into typescript 2022-03-30 14:44:07 -07:00
Keith Simmons
0dce371b3e Add assert_set_eq macro to make test clearer
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-30 13:53:38 -07:00
Keith Simmons
32d2e5952c Test language server restart works as expected
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-30 13:08:36 -07:00
Max Brunsfeld
3b4cab9094 Move all configuration of individual LSP servers to LspAdapter 2022-03-29 18:14:30 -07:00
Max Brunsfeld
ebc711f9f5 Restructure fake language server setup
Replace FakeLanguageServerConfig with FakeLanguageServerAdapter
2022-03-29 17:55:57 -07:00
Keith Simmons
ec57c1f4ac Properly dedup restarts of language servers 2022-03-29 17:46:39 -07:00
Keith Simmons
6d91fd078c Add restart-lsp keybinding 2022-03-29 17:24:23 -07:00
Max Brunsfeld
158d987965 Start work on allowing language servers to support multiple languages 2022-03-29 16:57:18 -07:00
Keith Simmons
0e1d371a67 Add typescript language server
Currently not tested for tsx files

Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-03-29 13:42:21 -07:00
Max Brunsfeld
a8600e76a3 Make language's language server config non-optional 2022-03-28 18:14:49 -07:00
Antonio Scandurra
cbd266052d Allow returning futures in fake language server request handlers 2022-03-28 10:44:32 +02:00
Nathan Sobo
a3e9a3afbf Clear out project registration and sharing state on disconnect
Previously, we weren't fully clearing the state associated with projects and worktrees when losing connection. This caused us to not see guest avatars disappear and not be able to re-share upon reconnect.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-03-25 10:15:08 -06:00
Antonio Scandurra
865cd1960f Preserve disk-based diagnostics whose ranges intersect with an edit since save
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-25 15:35:31 +01:00
Antonio Scandurra
a739c362d9 Rename editor::Event::Edited to editor::Event::BufferEdited
This is to distinguish it from a new event we're about to add which
represent edits originating from that specific editor.
2022-03-24 08:55:46 +01:00
Nathan Sobo
ee9ed936e4 Don't try keychain after authentication fails
Previously, we were achieving this by deleting the keychain item, but this can sometimes fail which leads to an infinite loop. Now, we explicitly never try the keychain when reattempting authentication after authentication fails.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-23 12:15:36 -06:00
Antonio Scandurra
e5a99cf8cd Stop following when leader disconnects 2022-03-22 11:16:04 +01:00
Antonio Scandurra
3117554568 Automatically unfollow when editing, scrolling or changing selections 2022-03-22 09:17:01 +01:00
Antonio Scandurra
f0b7bd6e17 Serialize initial follow state in leader and reflect it in follower 2022-03-18 10:22:13 +01:00
Max Brunsfeld
0fdaa1d715 WIP 2022-03-17 17:53:49 -07:00
Antonio Scandurra
4bbfd0918e Start defining follow protocol
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 16:50:29 +01:00
Antonio Scandurra
5d14c9abdf Introduce workspace::register_project_item
This lets downstream crates like `editor` define how project items should be
opened.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 15:54:34 +01:00
Antonio Scandurra
bff414cfbc Remove Editor::find_or_create
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-17 15:13:47 +01:00
Antonio Scandurra
6446660c88 Rename open_buffer_for_path to open_buffer 2022-03-17 11:42:13 +01:00
Nathan Sobo
728c708150 WIP: Massage opening of editors
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-03-16 17:40:09 -06:00
Nathan Sobo
0036e5c86c Replace ProjectEntry struct with ProjectEntryId
Previously, we tracked the worktree_id and entry_id separately, but now that entry ids are unique across all worktrees this is unnecessary.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Keith Simmons <keith@the-simmons.net>
2022-03-16 15:59:47 -06:00
Max Brunsfeld
a88320dc5f Remove workspace::Item trait
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Keith Simmons <keith@zed.dev>
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2022-03-16 13:34:06 -07:00
Antonio Scandurra
7155dabf5b Fade out unnecessary code
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 15:51:59 +01:00
Antonio Scandurra
021699e51c Implement shift-f8 to go to previous diagnostic
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-15 15:13:23 +01:00
Max Brunsfeld
3a439f141d Open settings file in new window if current window isn't local
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-14 17:12:07 -07:00
Max Brunsfeld
5822b47b74 Ensure that worktrees' entry ids are unique across the project
Fixes #512
2022-03-14 12:36:56 -07:00
Max Brunsfeld
20fed599b2 Start work on relaying settings to language servers 2022-03-11 17:36:27 -08:00
Antonio Scandurra
18b1e9d35f Don't starve main thread when lots of messages/events arrive at once 2022-03-11 10:09:13 +01:00
Antonio Scandurra
7a454003fe Show the last in-progress task from language servers 2022-03-11 09:59:13 +01:00
Antonio Scandurra
5157b42896 Extract a LanguageServerStatus struct 2022-03-10 18:43:56 +01:00
Antonio Scandurra
45fb470f4d Display language server name in status bar 2022-03-10 16:48:43 +01:00
Antonio Scandurra
4243f0c339 Render pending language server work in status bar 2022-03-10 16:09:47 +01:00
Antonio Scandurra
4bbf5ed0b9 Listen to all LSP progress notifications and broadcast them to peers 2022-03-10 12:00:33 +01:00
Antonio Scandurra
7546ede288 Split language server initialization from construction
This gives clients a chance to register to notifications.
2022-03-09 12:31:21 +01:00
Antonio Scandurra
ef1ec88523 Remove delegate support from GPUI
We added this because we thought it would save some allocations when
sending operations given that we could move them to the delegate upon
notifying it, but the reality is that we serialize operations and that
only requires a reference.
2022-03-09 10:48:52 +01:00
Antonio Scandurra
0a9595b5fa Notify all language servers only when a buffer is saved
Other notifications such as opening, closing or changing a document
are still tied to the buffer's language.
2022-03-09 10:44:03 +01:00
Max Brunsfeld
4cb4b99c56 Assign buffer's completion triggers from LSP capabilities
Also, make LanguageServer::new() async. The future resolves
once the server is initialized.
2022-03-08 17:41:52 -08:00
Antonio Scandurra
317a1bb07b Remove language servers from buffers
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-08 15:16:07 -08:00
Antonio Scandurra
6662ba62a3 Move DidSaveTextDocument notification from Buffer to Project 2022-03-08 11:35:54 +01:00
Antonio Scandurra
51d5ed48f0 Remove unused CloseBuffer message 2022-03-08 11:17:20 +01:00
Antonio Scandurra
d6c8fdb3c4 Send buffer operations via the Project instead of Worktree 2022-03-08 11:11:25 +01:00
Max Brunsfeld
5cc5fa2f93 Populate environment from shell
Co-Authored-By: Keith Simmons <keith@zed.dev>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-07 16:39:50 -08:00
Max Brunsfeld
1982a8c27d Put vector clock serialization logic alongside other serialization logic
This way, the `clock` crate doesn't depend on the `rpc` crate.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 13:54:07 -08:00
Nathan Sobo
a72d58a28c Merge branch 'main' into disconnected-status 2022-03-04 10:07:26 -07:00
Antonio Scandurra
b21d91db22 Render overlay after remote project becomes read-only
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-04 17:28:18 +01:00
Antonio Scandurra
6ee5e96d7b
Merge pull request #534 from zed-industries/create-buffers-via-project
Open untitled buffers via the `Project`
2022-03-04 16:18:02 +01:00
Antonio Scandurra
29cad65ce0 Open untitled buffers via the Project
This allows the registration of such buffers in the project, which is necessary
to correctly support `::save_buffer_as` and opens the door to sharing untitled
buffers with guests in the future.

Note that, for now, this disallows guests to create untitled buffers in the
current window and will create a new window instead. This is because we don't
yet have a global way of allocating a buffer's remote id (nor a way of saving
such buffers in the host's worktree) and we instead rely on the local model ID,
which could clash with the host's buffer IDs.

I think we should revisit this once guests can share their untitled buffers
with the host and other remote peers, as well as once we start keying
operations by entry id.
2022-03-04 15:25:39 +01:00
Antonio Scandurra
d8ef3a5d61 Support formatting in fake LSP capabilities 2022-03-04 11:24:18 +01:00
Antonio Scandurra
46da80d726 Use LSP range formatting when document formatting is not available 2022-03-04 10:13:17 +01:00
Antonio Scandurra
dc5a09b3f7
Merge pull request #525 from zed-industries/preserve-worktrees
Grow worktrees monotonically when sharing and move most messages to the background
2022-03-04 09:48:18 +01:00
Max Brunsfeld
19658139b1 Avoid infinite loop when a language server fails to start 2022-03-03 18:13:38 -08:00
Max Brunsfeld
05df1dfae9 Disable doctests for all libraries
We don't use them, and they add a lot of noise to the test output
when running all tests in the workspace.
2022-03-03 16:15:56 -08:00
Max Brunsfeld
3c242a43d2 Wait for LSP capabilities to be initialized before checking them 2022-03-03 15:59:03 -08:00
Max Brunsfeld
81627a0f14 Avoid sending unhandled LSP requests to JSON language server
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-03 13:39:40 -08:00
Antonio Scandurra
410ee124af Maintain remote worktrees correctly when building updates
This accidentally regressed in 53327e2.
2022-03-03 16:13:17 +01:00
Antonio Scandurra
c613b22619 Ignore diagnostics received for invisible worktrees 2022-03-03 13:58:55 +01:00
Antonio Scandurra
14d26eeedc Move several buffer-related messages to the background 2022-03-03 12:18:19 +01:00
Antonio Scandurra
1c14168f38 Ensure no two worktrees can point to the same root path
This could happen because there was a pause between creating the worktree
and adding it to the list of tracked local worktrees, and so we might end
up adding the same worktree twice when calling `create_local_worktree` in
rapid succession.
2022-03-03 10:54:52 +01:00
Antonio Scandurra
d171d8ccc4 Change the definition of check_invariants
- On the host, ensure that only one worktree can exist for a given absolute
path. Asserting about buffers was cool but I think should be tackled in the
context of leaning more on entry ids for collaboration (vs. buffer ids).
- On the guest, ensure that all the opened buffers don't contain deferred
operations.
2022-03-03 10:51:37 +01:00
Antonio Scandurra
53327e2bf0 Ensure worktree is registered/shared synchronously 2022-03-03 10:10:53 +01:00
Max Brunsfeld
d4ae38fcee Check projects' buffers have unique absolute paths in random collab test 2022-03-02 14:38:16 -08:00
Max Brunsfeld
ca920e1552 Rename strong_worktrees -> visible_worktrees 2022-03-02 14:38:16 -08:00
Antonio Scandurra
68cfce1fb8 Rename weak to visible
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-02 14:38:16 -08:00
Antonio Scandurra
07120d47f9 Convert weak worktree handles into strong handles when sharing
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-02 14:38:16 -08:00
Antonio Scandurra
efe7f61128 Use simulate_random_delay when polling snapshot only in tests
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-03-01 19:17:38 +01:00
Antonio Scandurra
c661ff251d Revert "Use async_broadcast to emit fake FS events"
This reverts commit 4cfd345f9d, because
having a bounded broadcast introduces the possibility of waiting forever
when there isn't yet a receiver processing those events.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 17:14:40 +01:00
Antonio Scandurra
0bb7189842 Use a weak handle to poll local worktree snapshot
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 17:08:10 +01:00
Antonio Scandurra
4cfd345f9d Use async_broadcast to emit fake FS events
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-03-01 15:48:15 +01:00
Antonio Scandurra
8d078ed4e2 Don't block when emitting fs events
Blocking could happen while processing events, which would cause the
background scanner to never make any further progress.
2022-03-01 13:08:50 +01:00
Antonio Scandurra
466db69780 Pass a reference to TestAppContext in tests
This allows us to drop the context *after* we ran all futures to
completion and that's crucial otherwise we'll never drop entities
and/or flush effects.
2022-03-01 12:01:02 +01:00
Max Brunsfeld
1faaa91e52 Avoid retaining executor in the FakeFs
This probably isn't the *root* cause of why an executor is leaked,
but by cutting off this cyclic references, it may make it a bit easier
to track down leaks of an executor.
2022-02-28 22:40:04 -08:00
Max Brunsfeld
d1d324e42b Never close buffers when sharing
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-28 11:36:43 -08:00
Antonio Scandurra
400a2fce58 Don't use a bounded channel for signaling that buffers have been opened
Blocking the sender could halt deserialization for no reason if nobody
is consuming the notifications.
2022-02-28 15:26:10 +01:00
Antonio Scandurra
1313ca8415 Don't delete buffer state when calling get_open_buffer
...as we might be in the process of completing a request that could
open a buffer. This was causing a failure in the randomized integration
test.
2022-02-28 14:27:31 +01:00
Antonio Scandurra
abdfdcdabf Include buffer's deferred ops when computing has_buffered_operations 2022-02-28 14:22:24 +01:00
Antonio Scandurra
720056d0db Add unit test for project search 2022-02-28 11:10:22 +01:00
Nathan Sobo
dd6f8d20a3 Remove carriage returns 2022-02-27 07:47:46 -07:00
Nathan Sobo
e822c6a64e Handle project-wide search on guests
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-25 15:09:47 -07:00
Antonio Scandurra
88bfe5acb0 Allow splitting project find and maintain the searches in sync 2022-02-25 16:20:02 +01:00
Antonio Scandurra
29e035a70d Don't report a buffer when it doesn't contain any matches 2022-02-25 15:40:19 +01:00
Antonio Scandurra
2147db9b41 Open searched buffers in parallel 2022-02-25 12:29:50 +01:00
Antonio Scandurra
561123d6de Avoid extra smol::channel when iterating through snapshot paths 2022-02-25 11:49:33 +01:00
Antonio Scandurra
6a0cca7178 Add a fast path for when the search query is empty 2022-02-25 10:58:45 +01:00
Antonio Scandurra
0bf944e038 Use Project::search in ProjectFind and show search results 2022-02-25 10:32:45 +01:00
Antonio Scandurra
6d9b003634 WIP: Start sketching in ProjectFindView
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-24 19:07:00 +01:00
Antonio Scandurra
e83d1fc9fc Start on a regex implementation of SearchQuery 2022-02-24 16:33:31 +01:00
Antonio Scandurra
76cc9b347e Extract a search module 2022-02-24 15:55:13 +01:00
Antonio Scandurra
6a323ce2dd Implement a basic project-wide search using Aho-Corasick 2022-02-24 15:33:56 +01:00
Antonio Scandurra
26f7f4f5b2 WIP: Remove ripgrep and start matching query for paths ourselves 2022-02-24 12:33:28 +01:00
Antonio Scandurra
119bfaa99f WIP 2022-02-24 11:57:53 +01:00
Antonio Scandurra
fed6f708c0 Start on project-wide find 2022-02-24 11:57:53 +01:00
Antonio Scandurra
8fa23c702c Store ops if buffer handle can't be upgraded and buffer requests are in-flight 2022-02-24 09:32:31 +01:00
Max Brunsfeld
a6613d5345 Store operations for unknown buffers when there are outstanding buffer RPC requests 2022-02-23 20:35:05 -08:00
Max Brunsfeld
6060077444 Remove unused pending_updates field from RemoteWorktree 2022-02-23 16:59:39 -08:00
Max Brunsfeld
170487a528 Fix race conditions with LSP requests that return buffers
* Avoid panic when registering a buffer that was previously open,
  and whose weak handle was still present in the open_buffers map.
* Avoid releasing any buffers while a request is outstanding which
  could return a reference to a buffer.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-23 15:26:01 -08:00
Nathan Sobo
17c9aa1819 Remove ShareWorktree message
Instead, create an empty worktree on guests when a worktree is first *registered*, then update it via an initial UpdateWorktree message.

This prevents the host from referencing a worktree in definition RPC responses that hasn't yet been observed by the guest. We could have waited until the entire worktree was shared, but this could take a long time, so instead we create an empty one on guests and proceed from there.

We still have randomized test failures as of this commit:

SEED=9519 MAX_PEERS=2 ITERATIONS=10000 OPERATIONS=7 ct -p zed-server test_random_collaboration

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-23 11:56:09 -07:00
Antonio Scandurra
d1b4384f80 WIP 2022-02-23 19:04:22 +01:00
Antonio Scandurra
8440644dc9 Remove update_id from worktree update messages
We don't need this anymore because worktree updates are foreground
messages.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-23 18:35:25 +01:00
Antonio Scandurra
f3c6320eeb Move document highlights RPC message to the background 2022-02-23 16:16:02 +01:00
Antonio Scandurra
9e173564e9 Pass an AsyncAppContext to fake language server request handlers 2022-02-23 16:14:36 +01:00
Max Brunsfeld
e140f70e3c Show document highlights from the language server when moving the cursor 2022-02-22 17:16:31 -08:00
Max Brunsfeld
25d45378e4 Implement find-all-references
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 14:27:16 -08:00
Max Brunsfeld
5d2201c4ca Add integration test for project symbols
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 12:44:17 -08:00
Max Brunsfeld
669fe775df Normalize paths passed to the FakeFs
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 12:43:56 -08:00
Max Brunsfeld
64098247cb Allow languages to be registered at any time
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-22 10:35:20 -08:00
Antonio Scandurra
d7db3791d5 Show worktree root name for symbol when there are multiple worktrees
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-22 18:57:41 +01:00
Antonio Scandurra
0e4bd4b418 Sign symbols so that we can trust opening buffers for them from guests
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-22 18:43:16 +01:00
Antonio Scandurra
fad335b2ba Don't serialize the full LSP symbol when collaborating
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 18:08:43 +01:00
Antonio Scandurra
72ad3c2897 Render paths in ProjectSymbolsView
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-22 17:48:14 +01:00
Antonio Scandurra
f0195ac3a3 Allow opening of buffers associated with a project symbol 2022-02-22 16:26:01 +01:00
Antonio Scandurra
2a6d486d14 Retrieve project symbols over RPC 2022-02-22 14:50:06 +01:00
Antonio Scandurra
ab73343323 WIP: Start on getting project symbols over RPC 2022-02-22 12:15:38 +01:00