Commit Graph
100 Commits
Author SHA1 Message Date
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
Kirill Bulatov 5322aa09b9 Properly handle settings toggle 2023-06-29 22:25:49 +03:00
Kirill Bulatov 8f68688a64 Allow readding inlays with existing ids, move inlay types 2023-06-29 22:25:49 +03:00
Kirill Bulatov 49c00fd571 Generate InlayIds in InlayMap, prepare InlayCache for refactoring 2023-06-29 22:25:49 +03:00
Kirill Bulatov e217a95fcc Cleanup the warnings 2023-06-29 22:25:49 +03:00
Kirill Bulatov 76d35b7122 Use proper, limited excerpt ranges and manage inlay cache properly 2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra 2b989a9f12 Fix all the tests
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra d4d88252c3 Fix most of the FoldMap random tests with inlays
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra f2c510000b Fix all FoldMap tests (without real inlays inside)
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra 29bb6c67b0 Fix first FoldMap methods after the map move
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra 9ae611fa89 Fix InlayMap bugs after the map order revers
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov 05dc672c2a Apply questionable changes to make things compile 2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra 10765d69f4 Move inlay map to be the first one
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra e744fb8842 Avoid having carriage returns (\r) in inlays
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra d2fef07782 Remove the SuggestionMap
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra 8cdf1a0faf Switch over to inlay map for Copilot suggestions
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra 34c6d66d04 Implement InlayBufferRows properly
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra bec9c26fa2 Fix more inlay_map corner cases and hangings
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra 02e124cec4 Fix inlay map tests
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov b231fa47af Apply hints setings on startup 2023-06-29 22:25:49 +03:00
Kirill Bulatov c898298c5c Properly update inlay hints when settings are changed 2023-06-29 22:25:49 +03:00
Kirill Bulatov 1ed52276e0 Add inlay hint settings 2023-06-29 22:25:49 +03:00
Kirill Bulatov ea837a183b Store inlays per paths and query on editor open 2023-06-29 22:25:49 +03:00
Kirill Bulatov 8acc5cf8f4 Deserialize more LSP inlay hint information 2023-06-29 22:25:49 +03:00
Kirill Bulatov f155f5ded7 Better rpc inlay hint handling 2023-06-29 22:25:49 +03:00
Kirill Bulatov b3aa75a363 Refresh inlays on buffer reopens 2023-06-29 22:25:49 +03:00
Kirill Bulatov e1f22c3684 Cache anchors from all versions, remove out of range hints 2023-06-29 22:25:49 +03:00
Kirill Bulatov 7abaf22b93 Generate proper inlay diffs for splice 2023-06-29 22:25:49 +03:00
Kirill Bulatov 6d1068d1e9 Query inlay hints for excerpt ranges only 2023-06-29 22:25:49 +03:00
Kirill Bulatov 271cd25a1d Display excerpt-ranged hints only 2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra addb62c1fc Fix the duplicate hints
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill BulatovandAntonio Scandurra 63074c5cd8 Better bias selection for hints that prefix the type
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2023-06-29 22:25:49 +03:00
Kirill Bulatov c7fa8dbc70 React with inlay updates on excerpt events 2023-06-29 22:25:49 +03:00