Rework inlay hover model (#2969)

Fixes
```
thread 'main' panicked at 'byte index 2 is not a char boundary; it is inside '…' (bytes 0..3) of `…)`'
```
panics like
https://zed-industries.slack.com/archives/C04S6T1T7TQ/p1694535396473329

by reworking the inlay hover model:
* avoid storing "hardcoded" coordinates of hovered inlay labels (such as
`InlayOffset`), instead, remember `inlay_id` and apply required
highlights there when hint with the same id is handled
* add randomized tests on inlay highlights
* sped up inlay hint cache lookup by inlay_id

As a downside, background highlights are no long appearing on inlay
hints, but Zed does not receive any tooltips for inlays anyway (r-a does
not send them for some reason, other LSP seem to have no such feature?),
so it does not matter now.
Nontheless, if the logic for displaying hint pop-ups is present and
works for harcoded tooltips in r-a, only background highlight is missing
now.

Release Notes:

- Fixed inlay hint highlights causing panic for certain cases with
"large" characters
This commit is contained in:
Kirill Bulatov 2023-09-15 10:40:02 +03:00 committed by GitHub
commit 8d3c251cc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 522 additions and 554 deletions

View file

@ -1012,7 +1012,7 @@ mod tests {
.unwrap();
editor.update(cx, |editor, cx| {
assert_eq!(
editor.all_background_highlights(cx),
editor.all_text_background_highlights(cx),
&[
(
DisplayPoint::new(2, 17)..DisplayPoint::new(2, 19),
@ -1033,7 +1033,7 @@ mod tests {
editor.next_notification(cx).await;
editor.update(cx, |editor, cx| {
assert_eq!(
editor.all_background_highlights(cx),
editor.all_text_background_highlights(cx),
&[(
DisplayPoint::new(2, 43)..DisplayPoint::new(2, 45),
Color::red(),
@ -1049,7 +1049,7 @@ mod tests {
.unwrap();
editor.update(cx, |editor, cx| {
assert_eq!(
editor.all_background_highlights(cx),
editor.all_text_background_highlights(cx),
&[
(
DisplayPoint::new(0, 24)..DisplayPoint::new(0, 26),
@ -1090,7 +1090,7 @@ mod tests {
editor.next_notification(cx).await;
editor.update(cx, |editor, cx| {
assert_eq!(
editor.all_background_highlights(cx),
editor.all_text_background_highlights(cx),
&[
(
DisplayPoint::new(0, 41)..DisplayPoint::new(0, 43),
@ -1301,7 +1301,7 @@ mod tests {
.unwrap();
editor.update(cx, |editor, cx| {
assert_eq!(
editor.all_background_highlights(cx),
editor.all_text_background_highlights(cx),
&[(
DisplayPoint::new(2, 43)..DisplayPoint::new(2, 45),
Color::red(),
@ -1328,7 +1328,7 @@ mod tests {
editor.next_notification(cx).await;
editor.update(cx, |editor, cx| {
assert_eq!(
editor.all_background_highlights(cx),
editor.all_text_background_highlights(cx),
&[(
DisplayPoint::new(0, 35)..DisplayPoint::new(0, 40),
Color::red(),

View file

@ -1725,7 +1725,7 @@ pub mod tests {
assert_eq!(
search_view
.results_editor
.update(cx, |editor, cx| editor.all_background_highlights(cx)),
.update(cx, |editor, cx| editor.all_text_background_highlights(cx)),
&[
(
DisplayPoint::new(2, 32)..DisplayPoint::new(2, 35),