Go back to old visible inlay hint mapping
Co-authored-by: David Kleingeld <davidsk@zed.dev>
This commit is contained in:
parent
81578c0d9e
commit
23c9eb875a
1 changed files with 158 additions and 154 deletions
|
@ -307,28 +307,36 @@ pub fn update_inlay_link_and_hover_points(
|
|||
let mut hover_updated = false;
|
||||
|
||||
if let Some(hovered_offset) = hovered_offset {
|
||||
// Get all visible inlay hints
|
||||
let visible_hints = editor.visible_inlay_hints(cx);
|
||||
|
||||
// Find if we're hovering over an inlay hint
|
||||
if let Some(hovered_inlay) = visible_hints.into_iter().find(|inlay| {
|
||||
// Only process hint inlays
|
||||
if !matches!(inlay.id, InlayId::Hint(_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the hovered position falls within this inlay's display range
|
||||
let inlay_start = snapshot.anchor_to_inlay_offset(inlay.position);
|
||||
let inlay_end = InlayOffset(inlay_start.0 + inlay.text.len());
|
||||
|
||||
hovered_offset >= inlay_start && hovered_offset < inlay_end
|
||||
}) {
|
||||
let buffer_snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let previous_valid_anchor = buffer_snapshot.anchor_at(
|
||||
point_for_position.previous_valid.to_point(snapshot),
|
||||
Bias::Left,
|
||||
);
|
||||
let next_valid_anchor = buffer_snapshot.anchor_at(
|
||||
point_for_position.next_valid.to_point(snapshot),
|
||||
Bias::Right,
|
||||
);
|
||||
if let Some(hovered_inlay) = editor
|
||||
.visible_inlay_hints(cx)
|
||||
.into_iter()
|
||||
.skip_while(|hint| {
|
||||
hint.position
|
||||
.cmp(&previous_valid_anchor, &buffer_snapshot)
|
||||
.is_lt()
|
||||
})
|
||||
.take_while(|hint| {
|
||||
hint.position
|
||||
.cmp(&next_valid_anchor, &buffer_snapshot)
|
||||
.is_le()
|
||||
})
|
||||
.max_by_key(|hint| hint.id)
|
||||
{
|
||||
let inlay_hint_cache = editor.inlay_hint_cache();
|
||||
let excerpt_id = hovered_inlay.position.excerpt_id;
|
||||
|
||||
// Extract the hint ID from the inlay
|
||||
if let InlayId::Hint(_hint_id) = hovered_inlay.id {
|
||||
if let Some(cached_hint) = inlay_hint_cache.hint_by_id(excerpt_id, hovered_inlay.id)
|
||||
if let InlayId::Hint(_hint_id) = hovered_inlay.id
|
||||
&& let Some(cached_hint) = inlay_hint_cache.hint_by_id(excerpt_id, hovered_inlay.id)
|
||||
{
|
||||
// Check if we should process this hint for hover
|
||||
let should_process_hint = match cached_hint.resolve_state {
|
||||
|
@ -404,8 +412,7 @@ pub fn update_inlay_link_and_hover_points(
|
|||
if part.tooltip.is_some() || part.location.is_some() {
|
||||
// Found the meaningful part - show hover for it
|
||||
let highlight_start = part_offset + extra_shift_left;
|
||||
let highlight_end =
|
||||
part_offset + part_len + extra_shift_right;
|
||||
let highlight_end = part_offset + part_len + extra_shift_right;
|
||||
|
||||
let highlight = InlayHighlight {
|
||||
inlay: hovered_inlay.id,
|
||||
|
@ -454,8 +461,7 @@ pub fn update_inlay_link_and_hover_points(
|
|||
editor,
|
||||
InlayHover {
|
||||
tooltip: HoverBlock {
|
||||
text: "Loading documentation..."
|
||||
.to_string(),
|
||||
text: "Loading documentation...".to_string(),
|
||||
kind: HoverBlockKind::PlainText,
|
||||
},
|
||||
range: highlight.clone(),
|
||||
|
@ -592,8 +598,7 @@ pub fn update_inlay_link_and_hover_points(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some((language_server_id, location)) = &part.location
|
||||
{
|
||||
if let Some((language_server_id, location)) = &part.location {
|
||||
if secondary_held
|
||||
&& !editor.has_pending_nonempty_selection()
|
||||
{
|
||||
|
@ -624,7 +629,6 @@ pub fn update_inlay_link_and_hover_points(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !go_to_definition_updated {
|
||||
editor.hide_hovered_link(cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue