Commit Graph

541 Commits

Author SHA1 Message Date
Antonio Scandurra
1eea2f3653 Add integration test for code actions 2022-02-14 11:42:56 +01:00
Antonio Scandurra
8d3b7e996f Proceed with saving a buffer even if formatting fails 2022-02-12 13:02:19 +01:00
Antonio Scandurra
a2100627c3 Refresh diagnostics and code actions more selectively 2022-02-12 13:01:55 +01:00
Max Brunsfeld
174c9d7ab0 Adjust multibuffer history test to reflect new behavior 2022-02-11 16:55:00 -08:00
Max Brunsfeld
d4b9d9e820 Inline MultiBuffer::format
Put all the logic in Editor. Add an `all_buffers` method so the editor can
format all of the buffers by itself.
2022-02-11 16:22:19 -08:00
Max Brunsfeld
06bb8d2779 Fix panic when canceling with a pending selection 2022-02-11 15:31:54 -08:00
Max Brunsfeld
01664d494c Restructure fake language server to setup request handlers in advance
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 15:08:56 -08:00
Max Brunsfeld
680d1fedc2 Always call set_selections in mouse selection methods
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 09:52:18 -08:00
Max Brunsfeld
947fe848c1 Make multibuffer anchor's buffer_id optional
Avoid using 0 for a buffer id on Anchor::min and max

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 09:51:47 -08:00
Nathan Sobo
fa194c8e14 Pass the pending selection to update_selections and set_selections
This helps us preserve our invariant of always having at least a pending selection in set_selections when comparing old and new cursor positions.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-11 10:07:42 -07:00
Nathan Sobo
ad9a0e2d4f Revert "Ensure there's always at least one selection in the editor"
This reverts commit b1a44b5816.
2022-02-11 09:21:04 -07:00
Antonio Scandurra
612a33147a Allow toggling of code actions
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 17:01:22 +01:00
Antonio Scandurra
7b28418979 Allow deployment of code actions from indicator
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 16:47:40 +01:00
Antonio Scandurra
b1a44b5816 Ensure there's always at least one selection in the editor
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 16:25:26 +01:00
Antonio Scandurra
a41725daee Render code actions indicator
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 16:01:15 +01:00
Antonio Scandurra
2fcdcac080 Fetch code actions on cursor movement instead of on-demand
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 14:41:19 +01:00
Antonio Scandurra
763d57c94a Don't return error when definition, completions, etc. are unavailable
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-11 13:16:17 +01:00
Antonio Scandurra
3fc3e51a44 Fix panic when trying to render a diagnostic that has no message 2022-02-11 12:16:20 +01:00
Antonio Scandurra
4929b8c525 Move Buffer::format to Project::format 2022-02-11 12:07:46 +01:00
Max Brunsfeld
424b35253a Don't open a multibuffer when code actions's edits are contained in the current editor
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-10 09:55:21 -08:00
Nathan Sobo
5049c1b286 Make Editor::newest_anchor_selection return a non-optional value
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
2022-02-10 10:16:54 -07:00
Nathan Sobo
93eb005f74 Correctly redo all undone edits after undoing in multi-buffer
When undoing edits performed in the multi-buffer, we also undo subsequent edits that may have occurred outside of the multi-buffer. This commit makes us redo those edits as well.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-10 09:26:20 -07:00
Nathan Sobo
c5b0b5f902 Store the oldest transaction id for each excerpted buffer in multi-buffer transactions
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-10 09:14:39 -07: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
d1f1563278 Push transaction into multi-buffer to allow undoing of a code action 2022-02-10 09:55:03 +01:00
Antonio Scandurra
dd223f93ec Allow editor to be saved when in multi-buffer mode
Also, this commit enables the customization of the title in a multi-buffer.
When specified, it will take precedence over a filename (or "untitled").
2022-02-10 09:35:19 +01:00
Antonio Scandurra
9ea535986f Fix push_excerpts_with_context_lines when ranges overlap 2022-02-10 09:06:11 +01:00
Max Brunsfeld
9749fea705 Start work on MultiBuffer::push_excerpts_with_context_lines
Use it in Editor::confirm_code_action
2022-02-09 18:28:15 -08:00
Max Brunsfeld
471c23e22f Allow inserting multiple excerpts in a batch
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-09 17:56:06 -08:00
Max Brunsfeld
aa7dfbdd9c Remove ExcerptProperties struct
Pass buffer and range as separate parameters

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-09 17:52:17 -08:00
Max Brunsfeld
b67be5ded3 Add MultiBufferItemHandle
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-09 17:09:03 -08:00
Max Brunsfeld
1ee15e1a59 Add and remove excerpts in randomized FoldMap and WrapMap tests 2022-02-09 14:43:24 -08:00
Max Brunsfeld
5b4c0d64bc Get tests passing and project diagnostics view working w/ new excerpt headers 2022-02-09 13:51:52 -08:00
Max Brunsfeld
3d9c39d0eb Silence warnings 2022-02-09 13:00:09 -08:00
Max Brunsfeld
fc70c6d4fd Fix BlockMap's handling of trailing empty excerpt updates with other edits
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-09 11:54:59 -08:00
Antonio Scandurra
cbf59ffafb Handle replacing trailing empty excerpt with another empty excerpt
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-09 19:38:18 +01:00
Antonio Scandurra
fab6f0c568 Add/remove excerpts in BlockMap randomized tests and fix resulting errors
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-02-09 19:10:13 +01:00
Antonio Scandurra
8d95dbe3e6 Render path headers in editor element
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-09 16:28:18 +01:00
Antonio Scandurra
f1e3d5285b Fix randomized test failures on BlockMap with excerpt headers
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-09 15:17:40 +01: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
c7e2fae9cb WIP - Add excerpt headers as a built-in feature of BlockMap
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-08 18:15:45 -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
624dbc1d0e Fix confirming completions in a multibuffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2022-02-08 15:05:34 -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
8bad05a4ba Don't populate editor's context menu state if there are no completions
This would accidentally stop the enter key from working.
2022-02-08 12:37:20 -08: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
dca974c7d4 Apply code actions remotely 2022-02-08 12:18:14 +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