Commit Graph

998 Commits

Author SHA1 Message Date
Antonio Scandurra
30e4ea1a4c Fix warnings 2022-02-17 17:26:03 +01:00
Antonio Scandurra
50a31721eb Wait for version before returning completions 2022-02-17 11:41:19 +01:00
Max Brunsfeld
e3c4ce208a Remove unnecessary waiting when handling save RPC requests
Add saving to the randomized integration test

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-16 17:47:21 -08:00
Max Brunsfeld
41ba980c9b Remove unnecessary waiting during completion RPC requests
Also, add completion requests to the randomized collaboration integration test,
to demonstrate that this is valid.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-16 17:23:16 -08:00
Max Brunsfeld
c4dff12d69 Allow multiple fake language servers to be started for a given project
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-16 16:10:36 -08:00
Max Brunsfeld
d358072c74 Include the desired version in a SaveBuffer RPC request
When handling this messages on the host, wait until the desired
version has been observed before performing the save.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-14 17:51:26 -08:00
Antonio Scandurra
fadb94afb2 Use selection instead of just the cursor when fetching code actions 2022-02-14 14:13:36 +01:00
Antonio Scandurra
e354133be0 Remove stray log statements 2022-02-12 12:32:57 +01:00
Max Brunsfeld
d84fc3beec Remove Buffer::apply_lsp_edits
Always use `edits_from_lsp`.
2022-02-11 16:22:19 -08:00
Antonio Scandurra
4929b8c525 Move Buffer::format to Project::format 2022-02-11 12:07:46 +01:00
Max Brunsfeld
645df73a37 Finish implementing Buffer::edits_from_lsp 2022-02-10 18:01:18 -08:00
Max Brunsfeld
3a1f9bb212 Start work on applying LSP edits via a diff
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-10 11:14:06 -08:00
Nathan Sobo
9936bb2efa Undo subsequent edits when undoing in multi-buffer
When undoing in the multi-buffer, don't preserve edits that occurred outside the multi-buffer after the edit being undone.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-10 09:04:53 -07:00
Antonio Scandurra
0e1318dfe4 WIP: Make editor crate compile again
Tests are still failing though.
2022-02-09 11:09:11 +01:00
Max Brunsfeld
8b1fb9a2cc Fix unused import warnings 2022-02-08 16:27:33 -08:00
Max Brunsfeld
6731d92f60 Give the editor a handle to the project, not a weak handle to the workspace
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-08 15:48:44 -08:00
Max Brunsfeld
93bcde953c Consolidate logic for completion alongside code actions in Project
This way, completions are dealt with more consistently with code actions,
and the logic is not spread across so many places. The `language::File`
trait and the multibuffer no longer need to deal with completions. Completions
are no longer generic over an anchor type.
2022-02-08 14:24:45 -08:00
Max Brunsfeld
722c84c976 Consolidate all code actions logic into Project 2022-02-08 13:17:57 -08:00
Max Brunsfeld
e0fe8b5a7c Merge branch 'main' into assists 2022-02-08 12:41:57 -08:00
Max Brunsfeld
a32dffdd2b Apply lsp edits in reverse order
This fixes the handling of multiple edits on the same line.
2022-02-08 12:41:30 -08:00
Antonio Scandurra
36ff31858b Set file in test_diagnostics to excercise language server 2022-02-08 20:09:53 +01:00
Antonio Scandurra
7d8641afb6 Make transactions serializable to enable edits on behalf of other users
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-08 19:48:21 +01:00
Antonio Scandurra
624eb5907e Serialize buffer in terms of operations rather than state
This is required because, after joining, we want to be able to refer
to operations that have happened prior to joining, which are not
captured by the state. There is probably a way of reconstructing operations
from the state, but that seems unnecessary and we've already talked about
wanting to have the server store operations rather than state once we start
persisting worktrees.
2022-02-08 14:59:46 +01:00
Antonio Scandurra
dca974c7d4 Apply code actions remotely 2022-02-08 12:18:14 +01:00
Antonio Scandurra
9ce3b1adf2 Send DidCloseTextDocument when dropping buffer
Closes https://github.com/zed-industries/zed/issues/434
2022-02-08 10:02:26 +01:00
Max Brunsfeld
e3f055d950 Use a pool of databases to speed up integration tests
Also, use env_logger consistently in the tests for each crate.
Only initiallize the logger at all if some RUST_LOG env var is set.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-07 15:00:00 -08:00
Antonio Scandurra
8f3ff1590e Apply edits received from LSP code actions and open all touched buffers 2022-02-07 18:48:45 +01:00
Antonio Scandurra
7a35ea7b25 Tolerate language servers reporting non-monotonic buffer versions
This isn't perfect but we'll retain up to 10 old versions just in case there
are race conditions in the language server. We haven't seen this in the wild
but we're concerned about diagnostic reporting racing with code action
resolution.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-07 16:29:05 +01:00
Antonio Scandurra
982e90539d WIP: Start on applying code actions 2022-02-07 12:20:03 +01:00
Nathan Sobo
93a3f4b615 Move rendering and select prev/next into ContextMenu enum
This prepares the way to have a code actions context menu.
2022-02-05 10:19:43 -07:00
Max Brunsfeld
83d4fe8e3a Start work on code actions
Just print out the returned code actions for now

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-04 17:45:00 -08:00
Max Brunsfeld
4900019e9b Add a ToPointUtf16 trait in text and multibuffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-04 17:35:37 -08:00
Max Brunsfeld
7fc951853d Adjust assertion to reflect rust grammar upgrade
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-04 13:31:41 -08:00
Max Brunsfeld
3e232f7115 Refine behavior of select_larger_syntax_node
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2022-02-04 13:19:00 -08:00
Max Brunsfeld
3dfff3866a Add integration test for getting and resolving completions 2022-02-03 15:24:16 -08:00
Antonio Scandurra
ab26a175a4 Opt into language-aware features when getting buffer chunks
We use chunks a lot to transform points and sync the various display maps,
and always querying tree-sitter or the LSP diagnostics in those cases is
unnecessarily expensive.
2022-02-03 11:21:30 +01:00
Antonio Scandurra
d246a39b57 Syntax highlight even when the label doesn't contain a detail 2022-02-03 09:57:04 +01:00
Max Brunsfeld
439d12cb85 Start work on syntax highlighting completions 2022-02-02 18:14:30 -08:00
Max Brunsfeld
45898daf83 Fix hang in editor completion unit test 2022-02-02 17:09:36 -08:00
Max Brunsfeld
bbdf62f263 Introduce Language::highlight_text method 2022-02-02 17:01:48 -08:00
Max Brunsfeld
88adddb324 Remove theme parameters from buffer/display map's chunks methods
Change Chunks to contain highlight ids instead of actual highlight
styles. Retrieve the actual highlight style from the theme in the
editor element layer.

This is to set us up to perform syntax highlighting in other code
paths where the theme is not available.
2022-02-02 16:33:04 -08:00
Antonio Scandurra
8149bcbb13 Improve formatting of function autocompletion labels in Rust
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-02 18:43:55 +01:00
Antonio Scandurra
8d7815456c Don't apply completion's edit when it wouldn't change the buffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-02 18:00:30 +01:00
Antonio Scandurra
924eb622ae Wait for additional edits before pushing transaction in remote buffer 2022-02-02 17:01:23 +01:00
Antonio Scandurra
d765e75bad Apply additional edits for completion when the buffer is remote 2022-02-02 16:29:13 +01:00
Antonio Scandurra
91e5c2dfac Broadcast completion triggers to remote participants 2022-02-02 14:07:41 +01:00
Antonio Scandurra
ed549e352f Start on requesting completions for remote buffers 2022-02-02 12:22:47 +01:00
Max Brunsfeld
7270fd00ba Start work on handling snippet completions 2022-02-01 15:35:02 -08:00
Max Brunsfeld
1371a20e58 🎨 Return an option task from confirm_completion 2022-02-01 14:27:01 -08:00
Antonio Scandurra
6c7d2cf6b5 Apply additional edits when confirming a completion
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-01 17:38:11 +01:00
Antonio Scandurra
bcc57036a5 Fix warnings in language::FakeFile
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-01 16:59:03 +01:00
Antonio Scandurra
b89a39bcb3 Filter and sort suggestions in autocomplete
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-01 15:11:20 +01:00
Nathan Sobo
fde03b1b37 Make the anchor range inclusive on completions
This will help us to correctly interpolate the replacement range when we confirm before receiving new completions after typing with a completion open.
2022-01-31 18:26:26 -07:00
Max Brunsfeld
1d1f8df180 Trigger completion when typing words or trigger characters
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-31 17:07:24 -08:00
Max Brunsfeld
8d2b7ba032 Insert completion text on enter
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-31 13:46:50 -08:00
Nathan Sobo
ab6eb0a655 Start on completion rendering
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-01-31 12:19:17 -07:00
Nathan Sobo
0344c543af Return anchored completions from Buffer::completions
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-01-31 11:25:00 -07:00
Antonio Scandurra
03bcbdc33d WIP 2022-01-31 19:12:35 +01:00
Antonio Scandurra
bd2527e691 Use StringMatchCandidate::new to construct candidates more conveniently
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-31 19:11:13 +01:00
Antonio Scandurra
f055053fc9 Avoid grouping transactions created by different editors
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-27 15:51:46 +01:00
Antonio Scandurra
121b45e249 Sanitize language server diagnostics coming from Rust
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-25 17:49:50 +01:00
Antonio Scandurra
96b66dcce1 Fix race condition when opening a buffer and getting a definition to it 2022-01-24 18:47:55 +01:00
Antonio Scandurra
245490f934 Implement Project::definition when the buffer is remote 2022-01-24 13:10:13 +01:00
Antonio Scandurra
f859d444ff Don't show conflict indicator on remote buffer after a reload 2022-01-24 10:17:36 +01:00
Antonio Scandurra
4372fe1ed0 Maintain remote buffers via UpdateBufferFile messages sent by host 2022-01-24 09:32:40 +01:00
Nathan Sobo
da13d028a3 Send File protos as part of Buffer protos
Use the File proto to build the File associated with the buffer rather than relying on the local entry.
2022-01-22 22:19:04 -07:00
Nathan Sobo
66fce5ec8e Introduce LocalFile trait
If you want to call `abs_path` or `load`, the file needs to be local. You call `as_local` which returns `Option<dyn LocalFile>` with those local-only methods. I think this makes it more explicit what works only locally vs everywhere.
2022-01-22 15:52:14 -07:00
Nathan Sobo
d192b6ebc7 Remove Worktree::abs_path
I'd like to only have methods related to absolute paths on local worktrees, because it's not really possible to implement them on remote worktrees since we don't know the full path being shared and wouldn't have anything to do with it anyway if we did.
2022-01-22 14:44:58 -07:00
Nathan Sobo
e2a2073bdb Remove worktree_path from File struct 2022-01-22 14:29:36 -07:00
Nathan Sobo
83418204b6 Assign diagnostics on buffer even if it doesn't have a language
This shouldn't be necessary in practice but makes testing easier.
2022-01-22 09:54:25 -07:00
Max Brunsfeld
bd49a02c92 Move buffers from worktree to project
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-21 15:46:27 -08:00
Antonio Scandurra
71082d4cdc Return a Task<Result<()>> in {ItemView,Buffer,MultiBuffer}::save 2022-01-20 09:58:24 +01:00
Max Brunsfeld
f43dcd6763 Move logic for starting language servers to the project 2022-01-19 14:05:06 -08:00
Max Brunsfeld
ea69dcd42a Match on names only when outline query has no spaces
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-14 09:16:29 -08:00
Nathan Sobo
b52db22544 Only enable smart case if the query contains an uppercase character
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-01-14 09:16:09 -07:00
Nathan Sobo
f934370e7f Match full path when query contains spaces
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-01-14 09:02:04 -07:00
Antonio Scandurra
be24e58926 Associate StringMatchCandidate with an id
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-14 14:55:03 +01:00
Antonio Scandurra
a64ba8b687 Allow matching of context items in outline view 2022-01-14 11:09:02 +01:00
Antonio Scandurra
9c1f58ee89 Maintain order of outline items when filling out tree's missing parts 2022-01-14 09:12:30 +01:00
Max Brunsfeld
adeb7e6864 Incorporate syntax highlighting into symbol outline view
Still need to figure out how to style the fuzzy match characters
now that there's syntax highlighting. Right now, they are
underlined in red.
2022-01-13 18:10:02 -08:00
Max Brunsfeld
7913a1ea22 Include highlighting runs in Outline 2022-01-13 14:46:15 -08:00
Max Brunsfeld
3e1c559b2d Allow multiple disjoint nodes to be captured as matcheable in the outline query 2022-01-13 14:04:25 -08:00
Antonio Scandurra
055d48cfb2 Select the closest outline item when the outline view's query is empty
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-01-13 18:43:49 +01:00
Antonio Scandurra
2660d37ad8 Return Outline<Anchor> from MultiBuffer::outline
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-01-13 18:24:00 +01:00
Antonio Scandurra
e165f1e16c Use OutlineItem::depth to include ancestors of matching candidates
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-13 16:59:52 +01:00
Antonio Scandurra
06ba1c64cf Implement Outline::search 2022-01-13 15:10:29 +01:00
Antonio Scandurra
d6ed2ba642 Start on rendering the outline view 2022-01-13 12:01:11 +01:00
Antonio Scandurra
ef596c64f8 Add OutlineItem::depth so that we can render a tree in the outline view 2022-01-13 11:35:43 +01:00
Max Brunsfeld
63a401ac5d Add Buffer::outline method
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-12 18:17:49 -08:00
Antonio Scandurra
66694b4c9a Fix failing tests
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-01-12 18:43:23 +01:00
Antonio Scandurra
310def2923 Implement Buffer::format
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-12 18:01:20 +01:00
Nathan Sobo
d7a78e14ac Allow disk-based diagnostic progress begin/end events to interleave
When multiple saves occur, we can have multiple start events followed by multiple end events. We don't want to update our project diagnostics view until all pending progress is finished.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-01-06 09:32:08 -07:00
Max Brunsfeld
fee7657fd7 Merge branch 'main' into polish-project-diagnostics 2022-01-05 20:38:20 -08:00
Max Brunsfeld
f9f75e98f8 Fix Locator::from_index
Enhance language::tests::test_random_collaborators so that it checks buffer invariants.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-05 17:58:24 -08:00
Max Brunsfeld
e5faaeb2f2 Fix Global::gt and rename it to changed_since
A false negative return value of `gt` was preventing guests' multibuffers from
syncing correctly.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-01-05 17:36:12 -08:00
Max Brunsfeld
8728d3292d Merge branch 'main' into polish-project-diagnostics
Also fix false failure in ModelHandle::condition when parking is not forbidden.
2022-01-05 10:53:18 -08:00
Antonio Scandurra
e56609cf0c Ensure prior, deferred selections don't override newer selections 2022-01-05 15:43:26 +01:00
Antonio Scandurra
f8c2620166 Fix Buffer::remote_selections_in_range at query range boundaries 2022-01-05 15:04:50 +01:00
Antonio Scandurra
587a908225 Populate deferred operations when an operation can't be applied 2022-01-05 15:04:19 +01:00
Antonio Scandurra
bf044506ed Verify that selections are replicated correctly in randomized test 2022-01-05 15:04:08 +01:00
Antonio Scandurra
870fa5f278 Serialize deferred operations 2022-01-05 11:52:41 +01:00
Antonio Scandurra
d383ff30ce Introduce randomized test for collaboration on buffers
This test will exercise serialization of operations as well as peers
replicating from an existing buffer.
2022-01-05 11:51:41 +01:00
Antonio Scandurra
7bc8eb4f3d Fix compile errors and get serialization unit test passing 2022-01-05 10:29:29 +01:00
Max Brunsfeld
984e366c32 WIP - Serialize buffer in terms of its state, not its base text + ops
The main reason for this is that we need to include information about
a buffer's UndoMap into its protobuf representation. But it's a bit
complex to correctly incorporate this information into the current
protobuf representation.

If we want to continue reusing `Buffer::apply_remote_edit` for
incorporating the historical operations, we need to either make
that method capable of incorporating already-undone edits, or
serialize the UndoMap into undo *operations*, so that we can apply
these undo operations after the fact when deserializing. But this is
not trivial, because an UndoOperation requires information about
the full offset ranges that were undone.
2022-01-04 18:06:16 -08:00
Max Brunsfeld
d7ecbdcc1d Add unit test showing problem with serialization of undo ops 2022-01-04 16:01:12 -08:00
Antonio Scandurra
b2f0c78924 Merge branch 'main' into polish-project-diagnostics
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-01-04 18:35:28 +01:00
Antonio Scandurra
ad1db117e6 Re-enable cargo check for rust-analyzer 2022-01-04 18:26:16 +01:00
Antonio Scandurra
508b9dc024 Rip out "diagnostic providers" 2022-01-04 16:32:17 +01:00
Antonio Scandurra
05a6137549 Capture a new buffer snapshot for excerpts whose selections got updated 2022-01-04 12:22:51 +01:00
Max Brunsfeld
7f8e76e0f1 Remove worktree-specific methods from language::File trait
Use downcasting instead for accessing worktree-specific state of the Files.

This will allow us to introduce a WorktreeId type and use that everywhere
for identifying worktrees. It also just removes some unnecessary coupling
between the language crate and the worktree.
2022-01-04 11:28:44 +01:00
Max Brunsfeld
cbd9e186b5 Store selections with a right start bias so that autoindent moves them
Previously, cursors at column 0 had to be explicitly moved when those lines
were autoindented. This behavior was lost when we moved selections from
the buffer to the editor. Now, with the right bias, we get this behavior automatically.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-27 15:33:57 -08:00
Max Brunsfeld
43db9e826b Clear autoindent requests when applying autoindent
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-27 13:33:48 -08:00
Nathan Sobo
cf81f5a555 Update tests to reflect that we no longer attempt to recycle group ids 2021-12-24 16:36:21 -07:00
Antonio Scandurra
a85e400b35 Start on a DiagnosticProvider implementation for Rust
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-24 16:22:22 +01:00
Antonio Scandurra
393009a05c Implement Buffer::diagnostic_group 2021-12-24 12:08:55 +01:00
Antonio Scandurra
11e3874b4a Remove duplication when assigning diagnostics and hardcode provider names 2021-12-24 12:07:26 +01:00
Max Brunsfeld
4f774e2bde wip 2021-12-23 23:10:28 -08:00
Max Brunsfeld
d5a17053df Get code compiling with some todos 2021-12-23 14:21:10 -08:00
Nathan Sobo
e3ecd87081 WIP
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-12-23 11:24:35 -07:00
Antonio Scandurra
7b453beebc WIP: Use cargo check for on-disk diagnostics
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-12-23 18:35:50 +01:00
Antonio Scandurra
b9d1ca4341 Show only disk-based diagnostics in ProjectDiagnosticsEditor
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-23 16:47:54 +01:00
Antonio Scandurra
dcf26acaac Use a different invalidation strategy for project-wide diagnostics 2021-12-23 15:41:43 +01:00
Antonio Scandurra
9164c5f239 Emit an UpdateDiagnostics from Worktree when buffer diagnostics change 2021-12-23 09:57:50 +01:00
Max Brunsfeld
5d8ed535be Clear out old disk-based diagnostics after 2 seconds 2021-12-22 15:51:51 -08:00
Max Brunsfeld
b9551ae8b1 Preserve group ids when updating diagnostics 2021-12-22 14:50:51 -08:00
Max Brunsfeld
0faf5308ac Add a unit test for preserving disk-based diagnostics 2021-12-22 13:27:43 -08:00
Max Brunsfeld
1544da887e Start work on preserving continuity of disk-based diagnostics 2021-12-22 12:52:50 -08:00
Max Brunsfeld
3c26f67ea3 Minor cleanup in Buffer::update_diagnostics 2021-12-21 14:07:50 -08:00
Max Brunsfeld
04d577e326 Fix context line handline in project diagnostic view 2021-12-21 11:46:47 -08:00
Max Brunsfeld
528d64d3cc WIP - Improve project diagnostic context rendering 2021-12-16 18:34:29 -08:00
Antonio Scandurra
1bdaeda43e Remove disk diagnostics that were invalidated by a buffer edit
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-12-15 18:29:01 +01:00
Nathan Sobo
6c5b27af1d Group diagnostics by primary
Render primary message above the excerpt and supporting messages as block decorations with a `Below` disposition. This is still super rough.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-12-14 18:26:42 -07:00
Antonio Scandurra
08e9f3e1e3 Maintain a different undo/redo stack in MultiBuffer
This only applies to singleton mode.
2021-12-14 17:43:41 +01:00
Max Brunsfeld
4efdc53d9f WIP 2021-12-13 17:44:20 -08:00
Max Brunsfeld
52b8e3d1a2 Get tests passing after diagnostic + selection changes
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-13 11:34:56 -08:00
Max Brunsfeld
418a9a3d66 Get things compiling with diagnostics on worktree
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-13 11:15:03 -08:00
Antonio Scandurra
85674ba506 WIP
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-13 16:46:35 +01:00
Antonio Scandurra
c984b39aaa Show remote collaborators' active selections 2021-12-13 11:38:38 +01:00
Nathan Sobo
cdbcbdfe6d Test undo/redo at editor layer, including selection restoration 2021-12-12 15:04:19 -07:00
Nathan Sobo
1e7184ea07 Get selections rendering again when local selections are owned by Editor 2021-12-11 13:42:46 -07:00
Nathan Sobo
4dd0752e80 More messy progress towards selections in editors 2021-12-11 00:29:34 -07:00
Nathan Sobo
8432daef6a WIP: Start on removing selections from buffer in favor of editor 2021-12-10 19:23:34 -07:00
Nathan Sobo
f35c419f43 Return optional transaction ids from undo/redo
This will allow the editor to restore selections that it associated with the start or end of a transaction.
2021-12-10 18:08:26 -07:00
Nathan Sobo
77defe6e28 Return optional transaction ids when starting/ending a transaction
If the transaction was nested, we return None. Otherwise we return the transaction id in preparation for editors to maintain their own selection state.
2021-12-10 18:00:09 -07:00
Nathan Sobo
c8b43e3078 Move multi_buffer to editor crate 2021-12-10 17:37:53 -07:00
Max Brunsfeld
6caf016df9 Get tests passing w/ multibuffer in editor
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-10 15:54:25 -08:00
Max Brunsfeld
75dd37d873 Update multibuffer when buffers' syntax trees or diagnostics change
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-10 15:54:06 -08:00
Max Brunsfeld
ceff57d02f Don't append a trailing newline in singleton MultiBuffer 2021-12-10 14:27:58 -08:00
Max Brunsfeld
a758bd4f8d Fill in some missing methods on MultiBuffer, MultiBufferSnapshot 2021-12-10 14:27:04 -08:00
Antonio Scandurra
5b31c1ba4e Start making MultiBuffer work with a singleton buffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-10 18:04:11 +01:00
Antonio Scandurra
7524974f19 Get everything compiling again
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-10 17:15:16 +01:00
Antonio Scandurra
da09247e5e WIP
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-10 16:14:12 +01:00
Antonio Scandurra
9c74deb9ec Finish removing anchor collections from MultiBuffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-10 15:58:37 +01:00
Antonio Scandurra
c8d5e19492 Merge branch 'fragment-locators' into project-diagnostics 2021-12-10 14:01:17 +01:00
Antonio Scandurra
cb97b7cd1d Fix diagnostic unit test 2021-12-10 09:43:21 +01:00
Max Brunsfeld
5e516f59c0 Merge branch 'fragment-locators' into HEAD 2021-12-09 14:49:04 -08:00
Antonio Scandurra
91a7bbbba2 Fix some of the diagnostic tests and make DiagnosticEntry generic
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-09 17:53:08 +01:00
Antonio Scandurra
65711b2256 Remove anchor collections
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-09 17:28:27 +01:00
Nathan Sobo
98f726974e WIP 2021-12-08 20:04:30 -07:00
Nathan Sobo
4ee404a0af Take a cx in MultiBuffer::start_transaction 2021-12-08 19:30:52 -07:00
Nathan Sobo
87d16c271e Get Editor compiling with MultiBuffer as its buffer
There's a bunch of unimplemented methods in MultiBuffer, but everything compiles.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-12-08 19:23:04 -07:00
Max Brunsfeld
daedf179b2 Implement Anchor, AnchorRangeMap, SelectionSet in multi_buffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-08 12:56:09 -08:00
Max Brunsfeld
a7634ccd5f Rename ExcerptList to MultiBuffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-08 10:07:15 -08:00
Max Brunsfeld
5f8e406c18 Fill out ExcerptList API
This restores the improvements that we had made on the `project-diagnostics-generic` branch.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-08 10:04:22 -08:00
Max Brunsfeld
fa379885f1 Give more specific names to all snapshot and text iterator types 2021-12-08 09:24:00 -08:00
Max Brunsfeld
ad33111a22 Fix assertion in excerpt unit test after fixing edits 2021-12-06 17:40:32 -08:00
Max Brunsfeld
39cc0cac93 Fix Subscription re-export after moving it into its own module 2021-12-06 17:40:17 -08:00
Max Brunsfeld
102926d171 Implement and randomized test excerpt list point translation and clipping 2021-12-06 17:39:31 -08:00
Max Brunsfeld
09c0c3a0e7 🎨 excerpt_list::Chunks::next 2021-12-06 16:28:44 -08:00
Max Brunsfeld
416033a01c Get random excerpts test passing w/ text in range, edits 2021-12-06 16:17:31 -08:00
Nathan Sobo
02f42f2877 WIP
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-12-06 14:51:23 -07:00
Nathan Sobo
88e3d87098 Get randomized test passing on basic excerpt list features
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-12-06 13:48:07 -07:00
Nathan Sobo
4578938ea1 Implement ExcerptList::subscribe
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-12-06 13:37:17 -07:00
Nathan Sobo
a02a29944c Get the basic ExcerptList unit test passing again
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-12-06 13:01:09 -07:00
Nathan Sobo
cff610e1ec Rename FragmentList to ExcerptList
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-12-06 11:59:32 -07:00
Antonio Scandurra
42eba7268d Introduce Buffer::edits_since_in_range
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-12-06 19:48:45 +01:00
Antonio Scandurra
e37908cf3b Start on a simple randomized test for FragmentList 2021-12-06 16:08:17 +01:00
Antonio Scandurra
8354d1520d 🎨 2021-12-06 14:03:38 +01:00
Antonio Scandurra
45d6f5ab04 Start on maintaining edits in FragmentList 2021-12-06 12:10:25 +01:00
Antonio Scandurra
8f90d42723 Merge branch 'main' into project-diagnostics 2021-12-06 09:39:03 +01:00
Max Brunsfeld
026c3476db Upgrade tree-sitter to 0.20.1 2021-12-05 21:37:08 -08:00
Nathan Sobo
0be897d5ac WIP: Edit one of the excerpted buffers and add an assertion
We'll need to detect edits on the child buffers and understand their impact on the tree.
2021-12-04 07:19:30 -07:00
Nathan Sobo
811696670a Start on a new FragmentList
Here I'm exploring a new approach to the project-wide diagnostics view that can exactly mirror the contents of cargo check. The `FragmentList` composes an arbitrary list of fragments from other buffers and presents them as if they were a single buffer.
2021-12-04 06:57:56 -07:00
Antonio Scandurra
e668ff8bcd Avoid allocating a Patch just to check if there are no edits
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-01 16:47:04 +01:00
Antonio Scandurra
733e0cb21b Use the new buffer subscription API to keep DisplayMap in sync
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-01 16:08:53 +01:00
Antonio Scandurra
3b536f153f Introduce text::Buffer::subscribe
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-12-01 15:55:05 +01:00
Antonio Scandurra
47c467dafc Bump FoldMap's version in FoldMap::sync (and not in DisplayMap) 2021-12-01 12:05:02 +01:00
Max Brunsfeld
faba276fdc WIP - maintain foldmap with Buffer::edits_since
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-30 17:23:02 -08:00
Max Brunsfeld
924e1578ea Use &Snapshot directly instead of impl Into<Content<'a>>
The text::Buffer and its snapshot already used the same representation
for their content, so we can just make Buffer deref to a Snapshot.
2021-11-30 13:32:11 -08:00
Nathan Sobo
1445ce10b5 Name the root file of every crate after the crate to ease navigation
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-11-30 12:46:39 -07:00
Nathan Sobo
d3f28166cb Rename buffer crate to text and name its entrypoint after the crate
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-11-30 12:26:12 -07:00
Antonio Scandurra
9d7039ed51 Embed a plain text grammar and override settings for that too 2021-11-29 18:01:51 +01:00
Antonio Scandurra
2c17ae9aa6 Introduce a new Grammar struct and allow it to be optional
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-29 17:38:59 +01:00
Antonio Scandurra
2f43ef67fd Allow a single start/end bias per AnchorRangeMap
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-25 16:53:10 +01:00
Max Brunsfeld
f0db748ba1 Implement toggle-comments 2021-11-23 14:13:28 -08:00
Nathan Sobo
2f39dee28b Use uniform biases in AnchorMap, AnchorRangeMap
Specifying a different bias for every point makes the interface feel pretty unwieldy and we don't really use it.
2021-11-22 15:30:46 -07:00
Max Brunsfeld
612b4404a9 Fix the bias of deserialized selection sets
Fixes #224

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-22 14:14:48 -08:00
Antonio Scandurra
b25c3eb740 Switch to a dense representation for clock::Global
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-22 17:20:43 +01:00
Antonio Scandurra
5094380c83 Enhance keyboard navigation when showing next diagnostic
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-18 16:55:18 +01:00
Antonio Scandurra
0e51365770 In a diagnostic group, mark the highest-severity diagnostic as primary
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-18 15:53:00 +01:00
Antonio Scandurra
0a6293bcda Support highlighting in blocks
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-18 14:08:21 +01:00
Nathan Sobo
52a4c15c14 Eliminate non-highlighted chunks APIs
Now we only have a single code path for chunks across all layers, but highlighting is optional and controlled by a flag.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-11-16 16:51:38 -08:00
Max Brunsfeld
8b1b35913a Fix group_ids assertions in diagnostics test
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-15 14:18:58 -08:00
Antonio Scandurra
4e32fabfdc Add text manipulation facilities to Rope for test purposes 2021-11-12 17:02:51 +01:00
Antonio Scandurra
2f4d8932dc Allow querying a diagnostic group by its id
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-04 15:16:59 +01:00
Antonio Scandurra
78bbb83448 Assign diagnostics a group_id based on their related_information
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-04 14:52:34 +01:00
Nathan Sobo
2d6285a6e1 Start on a test for grouped diagnostics 2021-11-03 18:47:18 -06:00
Max Brunsfeld
baf636a4a4 Extend empty diagnostic ranges at the ends of lines 2021-11-03 13:49:39 -07:00
Max Brunsfeld
8b5089c759 In the status bar, show the diagnostic under the cursor 2021-11-03 12:33:16 -07:00
Antonio Scandurra
c07d794249 Avoid ending the pending selection until updating selections
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-11-03 19:07:06 +01:00
Antonio Scandurra
9dc3c74260 Make resolving selections generic
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-11-03 17:51:57 +01:00
Antonio Scandurra
20a77f4c5e Fix test for disk-based diagnostics 2021-11-03 09:39:15 +01:00
Max Brunsfeld
8d3f42de52 Start language servers based on buffers' languages
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-02 17:41:01 -07:00
Max Brunsfeld
89392cd23d Avoid using worktree handle in File's path methods
This avoids a circular model update that was happening
when trying to retrieve the absolute path from a buffer's
file while applying remote operations.
2021-11-02 14:33:55 -07:00
Max Brunsfeld
1995bd89a6 Deserialize buffer's diagnostics
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-02 12:29:03 -07:00
Max Brunsfeld
61e06487b7 Avoid circular model update when sending diagnostics operations 2021-11-01 17:14:22 -07:00
Max Brunsfeld
0e62ddbb65 Replicate diagnostics to remote buffers
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-01 15:28:37 -07:00
Max Brunsfeld
40c861c249 Move protobuf logic from buffer crate to language crate
This will enable us to add operations that only pertain to the language crate.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-01 14:05:19 -07:00
Max Brunsfeld
78d97a3db2 Use Diagnostic struct in buffer's diagnostics multimap 2021-11-01 12:59:01 -07:00
Max Brunsfeld
1aee7bdb1d Delay quit until language servers are gracefully shut down
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-11-01 11:57:31 -07:00
Antonio Scandurra
6e5ec2a00d Take a &clock::Global instead of cloning in edits_since 2021-11-01 10:48:20 +01:00
Antonio Scandurra
f59be5fecf Always notify when receiving buffer operations
We had changed it to only emit a notification when the buffer was
actually edited, but we also want to notify when we receive non-edit
operations, such as a selection update.
2021-11-01 10:06:23 +01:00
Antonio Scandurra
b571eae4f3 Extend empty diagnostic ranges by one character
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-10-29 19:09:19 +02:00
Antonio Scandurra
6212ebad9b Communicate with language servers in terms of UTF-16 coordinates
This required indexing UTF-16 positions in `Rope`. We tried opting
into the UTF-8 experimental support but it didn't seem to work
correctly and the standard is UTF-16 anyway.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-10-29 18:33:23 +02:00
Antonio Scandurra
9c1b01521a Avoid unnecessary conversion to offsets in diagnostics_in_range 2021-10-29 14:41:41 +02:00
Max Brunsfeld
e1556893f7 Merge branch 'anchor-map-selections' into lsp 2021-10-28 17:08:06 -07:00
Max Brunsfeld
a1e576343e Rename AnchorRangeSet::to_point_ranges -> point_ranges 2021-10-28 16:32:49 -07:00
Max Brunsfeld
9bc08e446b Fix unit test for on-disk-changes to not rely on selection bias 2021-10-28 16:17:07 -07:00
Antonio Scandurra
ce8741977b Clip points coming from language server
This avoids panicking in Zed if the points they give us are invalid.

Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-10-28 19:02:26 +02:00
Antonio Scandurra
d12387b753 Ensure start endpoints always come before end endpoints
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2021-10-28 18:26:32 +02:00
Antonio Scandurra
ee78d6f17b Express multi-cursor edits using the new coordinate space
The language server expects that ranges further in the list of edits
account for the impact of prior changes in the edit list.
2021-10-28 13:40:55 +02:00
Antonio Scandurra
7091e0c567 Add a unit test for disk-based diagnostics 2021-10-28 11:37:24 +02:00
Antonio Scandurra
ac76706aa7 Sort LSP diagnostics by (start, end) 2021-10-28 11:36:33 +02:00
Nathan Sobo
9977248926 Adjust disk-based diagnostics based on edits since the last save
Still need to add tests... not sure if this is right yet.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2021-10-27 18:58:07 -06:00
Antonio Scandurra
bc076c1cc1 Update display map snapshots when diagnostics are updated
This is similar to what we do when we receive new parse trees from
tree-sitter.
2021-10-27 12:42:16 +02:00
Antonio Scandurra
a7a73a5b0b Fix bug in to_full_offset when Anchor::version != Content::version 2021-10-27 11:56:04 +02:00
Max Brunsfeld
c539069cbb Include diagnostic info in HighlightedChunks iterator
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-10-26 17:57:50 -07:00
Max Brunsfeld
ef4fc42d93 Allow retrieving a buffer's diagnostics 2021-10-26 15:46:08 -07:00
Max Brunsfeld
5bfbeb55c0 Simplify buffer constructor methods
Don't expose the `buffer::History` to callers of `language::Buffer`
2021-10-26 14:26:47 -07:00
Max Brunsfeld
7d5425e142 Move lsp configuration into language crate
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-10-26 12:17:51 -07:00
Max Brunsfeld
de8218314c Notify language server when saving a buffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-10-26 11:45:59 -07:00
Antonio Scandurra
0674e76864 WIP 2021-10-26 19:42:40 +02:00
Nathan Sobo
ab4f90a20a Get language and project compiling 2021-10-25 09:26:36 -06:00
Max Brunsfeld
282195b13e Assign new file handles on buffers when their files change on disk
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-10-21 13:08:54 +02:00
Max Brunsfeld
eb9d7c8660 Update buffer's saved mtime when file is reloaded after on-disk change
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-10-21 12:05:44 +02:00
Max Brunsfeld
eea0f35d38 Rename TextBuffer back to Buffer 2021-10-21 11:12:19 +02:00
Max Brunsfeld
37eae2ba67 Remove unnecessary dependencies in buffer and language crates 2021-10-21 09:40:50 +02:00
Max Brunsfeld
81a85e9c79 Extract a language crate 2021-10-20 22:51:40 +02:00