Commit Graph
100 Commits
Author SHA1 Message Date
Kirill Bulatov a884bd77e1 Slightly tidy up vector_db code
Avoid panicking when truncating code with special chars
2023-07-18 14:06:57 +03:00
Kirill BulatovandMax Brunsfeld a4bf19c5bd Simplify NoAction filtering logic
co-authored-by: Max Brunsfeld <max@zed.dev>
2023-07-17 20:42:35 +03:00
Kirill Bulatov 4cc06748c9 Ignore keybindings with NoAction in config overrides 2023-07-17 18:34:39 +03:00
Kirill Bulatov f5eac82e81 Reload menu after keybindings change 2023-07-17 12:30:42 +03:00
Kirill Bulatov eaa8224076 Use id instead of type_id for actions
Currently, both are the same thing, so the logic is not changed.
2023-07-17 12:24:56 +03:00
Kirill Bulatov cde5b3952d Select all matches (#2717)
Closes https://github.com/zed-industries/community/issues/75
Closes https://github.com/zed-industries/community/issues/1749

The PR 

* changes keybindings for `Editor && mode == auto_height` context:
before, `alt-enter` and `alt-shift-enter` added new lines in such
editors, including the one from buffer search.

New bindings are the same as in `Editor && mode == full` context.

* adds `search::SelectAllMatches` action and binds it to `Alt + Enter`
by default, to select all matches of a buffer search

The behavior mimics VSCode: we do not move the screen even if all
selections are out of the visible range (Cmd+G will navigate there) and
allow reselecting the results from both pane and search field, as long
as the search is not dismissed.

Release Notes:

- Added `search::SelectAllMatches` (`Alt + Enter` default) action to
place carets and select all buffer search results
([#75](https://github.com/zed-industries/community/issues/75),
[#1749](https://github.com/zed-industries/community/issues/1749)).
2023-07-14 21:37:04 +03:00
Kirill Bulatov b14cd5f56d Add a new button for the action 2023-07-14 17:32:10 +03:00
Kirill Bulatov ccc78000bd Preserve serach index for multicaret selection editor events 2023-07-14 14:47:12 +03:00
Kirill Bulatov f710efca3b Use a better name 2023-07-14 14:47:12 +03:00
Kirill Bulatov 2053418f21 Use VSCode-like shortcuts by default 2023-07-14 14:47:12 +03:00
Kirill Bulatov 29cbeb39bd Allow selecting all search matches in buffer 2023-07-14 14:47:12 +03:00
Kirill Bulatov c2ffd8975b Update another deprecated plugin (#2716)
Follow-up of https://github.com/zed-industries/zed/pull/2713, fixing the
same for the bundling part of the pipeline.

Release Notes:

- N/A
2023-07-13 12:12:42 +03:00
Kirill Bulatov 8cce403c11 Update another deprecated plugin 2023-07-13 11:52:35 +03:00
Kirill Bulatov 1e8ee5361d Update GH Actions (#2713)
Fixes deprecation warnings the CI jobs started to have:

https://github.com/zed-industries/zed/actions/runs/5535503789

<img width="1383" alt="image"
src="https://github.com/zed-industries/zed/assets/2690773/a33ecc2a-d6d3-451d-8033-da5754df4731">

Release Notes:

- N/A
2023-07-12 22:25:59 +03:00
Kirill Bulatov 7cbcc28b1b Update checkout actions 2023-07-12 22:18:37 +03:00
Kirill Bulatov d164034198 Allow all completions with preresolved additional text edits (#2711)
Deals with https://github.com/zed-industries/community/issues/752
Deals with https://github.com/zed-industries/community/issues/566

Currently, when converting from LSP to Zed objects, completions with
non-empty `additional_text_edits` are filtered out.
Later, all other completions form a list and the selected one gets the
`Editor::confirm_completion` call, which always queries an LSP
completion resolve request to get the `additional_text_edits` field.

Otherwise, `additional_text_edits` field is ignored entirely for the
rest of the completion lifetime — and we always pass the selected
completion through the resolve request.

The PR changes the logic, removing the `additional_text_edits` filtering
and instead of resolving every completion, now we check for
`additional_text_edits` in the completion before resolving: resolve
happens only if the data is absent.

Generally, feels like resolve has to happen before the completion
selection: LSP servers may send us markdown for completion documentation
preview pop ups and similar extra info.
Also, the server may lack resolve capabilities entirely, always sending
the request seems dangerous.
For now, the PR does not attempt to change either.

Release Notes:

- Brings rust-analyzer's postfix completions and others completions with
preresolved additional text edits
2023-07-12 22:10:18 +03:00
Kirill BulatovandMax Brunsfeld 0c7949bdee Force resolve all completions, to ensure their edits are up-to-date
co-authored-by: Max Brunsfeld <max@zed.dev>
2023-07-12 21:10:01 +03:00
Kirill Bulatov c732aa1617 Do not resolve completions if extra edits are available 2023-07-12 20:28:16 +03:00
Kirill Bulatov 6d96c6ef51 Draft the postfix completions support 2023-07-12 18:32:03 +03:00
Kirill Bulatov 5483bd1404 Refactor LSP restart logic (#2705)
Instead of storing `initialization_options` in every LSP adapter as
before, store previous LSP settings in `Project` entirely.

This way, we can later have use multiple different project
configurations per single LSP with its associated adapter.

Release Notes:

- N/A
2023-07-11 22:09:40 +03:00
Kirill BulatovandMax Brunsfeld 4b4d049b0a Refactor LSP restart logic
Instead of storing `initialization_options` in every LSP adapter as
before, store previous LSP settings in `Project` entirely.

This way, we can later have use multiple different project
configurations per single LSP with its associated adapter.

co-authored-by: Max Brunsfeld <max@zed.dev>
2023-07-11 21:56:55 +03:00
Kirill Bulatov efe8b8b6d0 Revert "Fix language servers improper restarts"
This reverts commit 91832c8cd8.
2023-07-11 20:46:45 +03:00
Kirill Bulatov 8161438a85 Fix language servers improper restarts (#2702)
Fixes
https://linear.app/zed-industries/issue/Z-2595/language-servers-are-unnecessarily-restarted-when-unrelated-settings

Language servers mixed `initialization_options` from hardcodes and user
settings, fix that to ensure we restart servers on their settings
changes only.

Release Notes:

- N/A
2023-07-11 17:15:19 +03:00
Kirill Bulatov 748e7af5a2 Add a test 2023-07-11 17:10:34 +03:00
Kirill Bulatov 91832c8cd8 Fix language servers improper restarts
Language servers mixed `initialization_options` from hardcodes and user
settings, fix that to ensure we restart servers on their settings
changes only.
2023-07-11 16:36:20 +03:00
Kirill Bulatov 4ab2b8b24b Restart LSP server on corresponding initialization_options change (#2690)
Inlay hints depend on LSP server settings, but servers do not update the
initialization options and query hints with old settings.

Generally, we cannot know whether a certain option can be changed
without server restart, which the name of the options implies too, so be
on the safe side and restart the server.
Hints will update automatically after the server either sends a /refresh
request or reports its work progress end after startup.

Release Notes:

- Fixed LSP server not restarting after `initialization_options`
settings changes
2023-07-06 23:32:34 +03:00
Kirill Bulatov e6ec0af743 Remove redundant hint kind checks in tests 2023-07-06 23:27:25 +03:00
Kirill Bulatov fff65968bf Restart LSP server on initialization options change 2023-07-06 23:27:22 +03:00
Kirill Bulatov 2c7e5e0671 Clip find preceding boundary (#2689)
Fixes inability to do `alt + left arrow` when an inlay with `Bias::Left`
is right to the left of the caret.

Release Notes:

- N/A
2023-07-06 17:24:03 +03:00
Kirill Bulatov 11ae99fbd6 Add a test 2023-07-06 17:16:34 +03:00
Kirill Bulatov 348c93e8bb Show inlay hints on startup for every language server with work events (#2686)
Closes https://linear.app/zed-industries/issue/Z-2537/inlay-hint-issues

Language servers such as typescript-language-servers report a single
work event, ending right after server's startup.

Other servers might send more similar event, also during startup. The
rest of the events are diagnostic-related and we filter them out.

React on such events with /refresh-like hint update, that will check
only the visible part of the editor for hints and might be replaced by
other /refresh requests, if needed.

Release Notes:

- N/A
2023-07-06 16:18:22 +03:00
Kirill Bulatov 0b0a161626 Show inlay hints on startup for every language server with work events
Language servers such as typescript-language-servers report a single
work event, ending right after server's startup.

Other servers might send more similar event, also during startup.
The rest of the events are diagnostic-related and we filter them out.

React on such events with /refresh-like hint update, that will check
only the visible part of the editor for hints and might be replaced by
other /refresh requests, if needed.
2023-07-06 13:10:59 +03:00
Kirill Bulatov c298cf7527 Use less padding for typescript parameter hints (#2684)
Part of https://linear.app/zed-industries/issue/Z-2537/inlay-hint-issues

Release Notes:

- N/A
2023-07-06 11:23:20 +03:00
Kirill Bulatov 1936bdebb3 Use less padding for typescript parameter hints 2023-07-06 11:16:39 +03:00
Kirill Bulatov 91a94d299e Simplify inlay map data (#2683)
Current logic does not need to access inlays by id in O(1), future
dynamic hints would need to know which hint they hover at, but that will
be done using binary search over the position's anchor we hover on;
nothing else seems to need this HashMap in the near future.

Because of that removal, no need to store `InlayId` apart from the
`Inlay`, hence remove the `InlayProperties` struct entirely.
This allows to eliminate a few generics along the way.

Release Notes:

- N/A
2023-07-05 16:31:47 +03:00
Kirill Bulatov d7f6b5e1a0 Remove InlayProperties 2023-07-05 16:17:14 +03:00
Kirill Bulatov 6ba1c3071a Simplify inlay map data 2023-07-05 15:23:56 +03:00
Kirill Bulatov 31483db5d8 Accept null as a valid action, to disable a keystroke (#2678)
Deals with https://github.com/zed-industries/community/issues/772
Closes
https://linear.app/zed-industries/issue/Z-1518/allow-keybindings-to-be-removed

Now, configuration like 
```json5
[
    {
        "context": "Editor",
        "bindings": {
            "alt-v": null,
        }
    }
]
```

will make `alt+v` to print `√` instead of moving the caret one page up.

Release Notes:

- Added a way to disable keybindings with `null` value
2023-07-04 21:51:46 +03:00
Kirill BulatovandMikayla Maki 4c51ab8a25 Accept null as a valid action, to disable a keystroke
co-authored-by: Mikayla Maki <mikayla@zed.dev>
2023-07-04 21:11:28 +03:00
Kirill Bulatov 6c01aeaf77 Do not perform OnTypeFormating after pair brace insert (#2672)
Closes
https://linear.app/zed-industries/issue/Z-2358/ra-brace-auto-surround-causes-duplicate-end-char-with-selection

Release Notes:

- Fixed a bug when duplicate brace appeared after selected text got
surrounded with braces
2023-07-03 17:26:55 +03:00
Kirill BulatovandJulia Risley 85701c9b80 Do not perform OnTypeFormating after pair brace insert
Co-Authored-By: Julia Risley <julia@zed.dev>
2023-07-03 17:21:44 +03:00
Kirill Bulatov 8efb66be67 Do not add extra spaces to hints (#2671)
Closes
https://linear.app/zed-industries/issue/Z-2526/inlay-hints-in-typescript-types-have-extra-space-before#comment-ac88a101

Release Notes:

- N/A
2023-07-03 11:18:07 +03:00
Kirill Bulatov 43d4f04331 Do not add extra spaces to hints 2023-07-03 11:17:12 +03:00
Kirill Bulatov e017d62e92 Remove excessive hint update queries (#2667)
Closes
https://linear.app/zed-industries/issue/Z-2513/panic-in-refresh-inlay-hints

* Filter out queries for outdated buffers just before hint tasks spawn:
  multicaret edits might emit standalone events simultaneously
* Only spawn inlay update tasks for visible buffers with corresponding
  language
* Do not spawn tasks for local projects' buffers without LSP servers

Release Notes:

- N/A
2023-06-30 22:15:36 +03:00
Kirill Bulatov ae54e1d224 Remove excessive hint update queries
* Filter out queries for outdated buffers just before hint tasks spawn:
  multicared edits might empit standalone events simultaneously
* Only spawn inlay update tasks for visible buffers with corresponding
  language
* Do not spawn tasks for local projects' buffers without LSP servers
2023-06-30 22:03:21 +03:00
Kirill Bulatov 167dd1c5d2 Support basic inlay hints (#2660)
Part of https://github.com/zed-industries/community/issues/138
Part of https://linear.app/zed-industries/issue/Z-477/inlay-hints

Supports LSP requests for inlay hints, LSP /refresh request to reload
them.
Reworks DisplayMap and underlying layer to unite suggestions with inlay
hints into new, `InlayMap`.
Adds a hint cache inside `Editor` that tracks buffer/project/LSP request
events, updates the hints and ensures opened editors are showing up to
date text hints on top.

Things left to do after this PR:
* docs on how to configure inlay hints
* blogpost
* dynamic hints: resolve, hover, navigation on click, etc.

Release Notes:

- Added basic support of inlay hints
2023-06-29 22:49:39 +03:00
Kirill Bulatov b146762f68 Remove a flacky test, fix the failing one 2023-06-29 22:45:04 +03:00
Kirill Bulatov 652909cdba Post-rebase fixes 2023-06-29 22:39:33 +03:00
Kirill Bulatov 3445bc42b6 Invalidate refresh tasks better 2023-06-29 22:39:18 +03:00
Kirill Bulatov 98edc0f885 Simplify the hint cache code 2023-06-29 22:39:18 +03:00
Kirill Bulatov 083e4e76e2 Better tests, invalidate multibuffer excerpts better 2023-06-29 22:39:18 +03:00
Kirill Bulatov 943c93fda7 Simplify hint task queueing 2023-06-29 22:39:18 +03:00
Kirill Bulatov 30e77aa388 More inlay hint cache tests 2023-06-29 22:39:18 +03:00
Kirill BulatovandAntonio Scandurra 429a9cddae Use fold points to go to display map's prev/next line boundary
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:39:18 +03:00
Kirill BulatovandAntonio Scandurra bb9ade5b6f Fix wrap map test
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:39:18 +03:00
Kirill BulatovandAntonio Scandurra 2b59f27c3b Fix fold map tests
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:39:18 +03:00
Kirill Bulatov 0972766d1d Add more hint tests 2023-06-29 22:39:18 +03:00
Kirill Bulatov 15e0feb91d Move highlights from fold to inlay randomized tests 2023-06-29 22:39:18 +03:00
Kirill Bulatov 667b70afde Move hint settings on the language level 2023-06-29 22:39:18 +03:00
Kirill Bulatov 480d8c511b Theme hints and suggestions differently 2023-06-29 22:39:18 +03:00
Kirill BulatovandAntonio Scandurra 3312c9114b Improve inlay hint highlights
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:39:18 +03:00
Kirill Bulatov 2c54d926ea Test inlay hint cache 2023-06-29 22:39:18 +03:00
Kirill Bulatov 67214f0e55 Only skip /refresh inlay queries when vislble range is not updated 2023-06-29 22:25:50 +03:00
Kirill Bulatov 096bad1f73 Revert useless changes, simplify 2023-06-29 22:25:50 +03:00
Kirill Bulatov 5c21ed4263 Properly filter out task hints 2023-06-29 22:25:50 +03:00
Kirill Bulatov dfb30218ca Remove mutex usage from *Map contents 2023-06-29 22:25:50 +03:00
Kirill Bulatov acef5ff195 Query hints when editors gets open and visible 2023-06-29 22:25:50 +03:00
Kirill Bulatov 11fee4ce42 Do not eagerly cancel running tasks 2023-06-29 22:25:49 +03:00
Kirill Bulatov 4d4544f680 Split excerpts into mutliple ranges for inlay hint queries 2023-06-29 22:25:49 +03:00
Kirill Bulatov 2c7900e11b Use excerpt visible range in query filtering 2023-06-29 22:25:49 +03:00
Kirill Bulatov 83b3a914bc Support better inlay cache parallelization 2023-06-29 22:25:49 +03:00
Kirill Bulatov 890b164278 Forward inlay hint refresh requests to clients, test coop inlay hints 2023-06-29 22:25:49 +03:00
Kirill Bulatov a68e68a0d9 Properly filter out new hints outside of excerpts' visible ranges 2023-06-29 22:25:49 +03:00
Kirill Bulatov ba3d1e4dba Deduplicate inlay hints queries with buffer versions 2023-06-29 22:25:49 +03:00
Kirill Bulatov f25a09bfd8 Avoid excessive allocations with Arc around excerpt cached inlays 2023-06-29 22:25:49 +03:00
Kirill Bulatov 48982c3036 Filter away new hints not in excerpt range 2023-06-29 22:25:49 +03:00
Kirill Bulatov 316e19ce94 Remove stale cancelled inlay hints workaround 2023-06-29 22:25:49 +03:00
Kirill BulatovandMax Brunsfeld 96a34ad0ee Use text anchors as hint position in hints cache
co-authored-by: Max Brunsfeld <max@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov 781fa0cff4 Deduplicate LSP requests on multibuffer scroll 2023-06-29 22:25:49 +03:00
Kirill Bulatov c61de29c11 Use proper anchors for remote LSP queries 2023-06-29 22:25:49 +03:00
Kirill Bulatov cb4b92aa61 Simplify hint event management slightly 2023-06-29 22:25:49 +03:00
Kirill Bulatov d59e91aff2 Insert new hints into cache better 2023-06-29 22:25:49 +03:00
Kirill Bulatov d6828583d8 Box the cache for better performance 2023-06-29 22:25:49 +03:00
Kirill Bulatov 1722d61190 Mitigate odd offset calculations 2023-06-29 22:25:49 +03:00
Kirill Bulatov 7fddc223cd Move away heavy inlay computations into background tasks 2023-06-29 22:25:49 +03:00
Kirill Bulatov 31f0f9f7b1 Forbid extra inlay updates 2023-06-29 22:25:49 +03:00
Kirill Bulatov 97e5d40579 Add snapshot version to use when avoiding wrong state updates 2023-06-29 22:25:49 +03:00
Kirill Bulatov 8d982a6c2d Finish modelling 2023-06-29 22:25:49 +03:00
Kirill Bulatov 4c78019317 Start to model the background threads for InlayHintCache 2023-06-29 22:25:49 +03:00
Kirill Bulatov 2f1a27631e React on multibuffer scrolls again 2023-06-29 22:25:49 +03:00
Kirill Bulatov a31d3eca45 Spawn cache updates in separate tasks 2023-06-29 22:25:49 +03:00
Kirill Bulatov 3b9a2e3261 Do not track editor ranges in InlayHintCache 2023-06-29 22:25:49 +03:00
Kirill Bulatov 70a45fc800 Fix cache incremental updates 2023-06-29 22:25:49 +03:00
Kirill Bulatov 7ac1885449 Properly refresh hints on editor open 2023-06-29 22:25:49 +03:00
Kirill Bulatov 58343563ba Fix hint querying bugs 2023-06-29 22:25:49 +03:00
Kirill Bulatov debdc3603e Finish rest of the inlay cache logic 2023-06-29 22:25:49 +03:00
Kirill Bulatov ddcbc73bf0 Implement inlay hint replaces for conflict-less case 2023-06-29 22:25:49 +03:00
Kirill Bulatov 6368cf1a27 Merge excerpt-related hint data, move next_inlay_id into Editor 2023-06-29 22:25:49 +03:00
Kirill Bulatov 8c03e9e122 Move InlayId generation back to InlayCache 2023-06-29 22:25:49 +03:00
Kirill Bulatov e82b4d8957 Properly handle hint addition queries 2023-06-29 22:25:49 +03:00