Commit graph

236 commits

Author SHA1 Message Date
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