Debounce refresh of inlay hints on buffer edits (#8282)

I think this makes it less chaotic to edit text when the inlay hints are
on.

It's for cases where you're editing to the right side of an inlay hint.
Example:

```rust
for name in names.iter().map(|item| item.len()) {
    println!("{:?}", name);
}
```

We display a `usize` inlay hint right next to `name`.

But as soon as you remove that `.` in `names.iter` your cursor jumps
around because the inlay hint has been removed.

With this change we now have a 700ms debounce before we update the inlay
hints.

VS Code seems to have an even longer debounce, I think somewhere around
~1s.

Release Notes:

- Added debouncing to make it easier to edit text when inlay hints are
enabled and to save rendering of inlay hints when scrolling. Both
debounce durations can be configured with `{"inlay_hints":
{"edit_debounce_ms": 700}}` (default) and `{"inlay_hints":
{"scroll_debounce_ms": 50}}`. Set a value to `0` to turn off the
debouncing.


### Before


https://github.com/zed-industries/zed/assets/1185253/3afbe548-dcfb-45a3-ab9f-cce14c04a148



### After



https://github.com/zed-industries/zed/assets/1185253/7ea90e42-bca6-4f6c-995e-83324669ab43

---------

Co-authored-by: Kirill <kirill@zed.dev>
This commit is contained in:
Thorsten Ball 2024-02-27 11:18:13 +01:00 committed by GitHub
parent cbdc07dcd0
commit ddca6a3fb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 137 additions and 19 deletions

View file

@ -383,7 +383,9 @@ To override settings for a language, add an entry for that language server's nam
"enabled": false,
"show_type_hints": true,
"show_parameter_hints": true,
"show_other_hints": true
"show_other_hints": true,
"edit_debounce_ms": 700,
"scroll_debounce_ms": 50
}
```
@ -402,6 +404,9 @@ The following languages have inlay hints preconfigured by Zed:
Use the `lsp` section for the server configuration. Examples are provided in the corresponding language documentation.
Hints are not instantly queried in Zed, two kinds of debounces are used, either may be set to 0 to be disabled.
Settings-related hint updates are not debounced.
## Journal
- Description: Configuration for the journal.