Restore previous hovered_offset logic
Co-authored-by: David Kleingeld <davidsk@zed.dev>
This commit is contained in:
parent
70918609d8
commit
81578c0d9e
1 changed files with 157 additions and 151 deletions
|
@ -298,14 +298,15 @@ pub fn update_inlay_link_and_hover_points(
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Editor>,
|
cx: &mut Context<Editor>,
|
||||||
) {
|
) {
|
||||||
// For inlay hints, we need to use the exact position where the mouse is
|
let hovered_offset = if point_for_position.column_overshoot_after_line_end == 0 {
|
||||||
// But we must clip it to valid bounds to avoid panics
|
Some(snapshot.display_point_to_inlay_offset(point_for_position.exact_unclipped, Bias::Left))
|
||||||
let clipped_point = snapshot.clip_point(point_for_position.exact_unclipped, Bias::Left);
|
} else {
|
||||||
let hovered_offset = snapshot.display_point_to_inlay_offset(clipped_point, Bias::Left);
|
None
|
||||||
|
};
|
||||||
let mut go_to_definition_updated = false;
|
let mut go_to_definition_updated = false;
|
||||||
let mut hover_updated = false;
|
let mut hover_updated = false;
|
||||||
|
|
||||||
|
if let Some(hovered_offset) = hovered_offset {
|
||||||
// Get all visible inlay hints
|
// Get all visible inlay hints
|
||||||
let visible_hints = editor.visible_inlay_hints(cx);
|
let visible_hints = editor.visible_inlay_hints(cx);
|
||||||
|
|
||||||
|
@ -327,7 +328,8 @@ pub fn update_inlay_link_and_hover_points(
|
||||||
|
|
||||||
// Extract the hint ID from the inlay
|
// Extract the hint ID from the inlay
|
||||||
if let InlayId::Hint(_hint_id) = hovered_inlay.id {
|
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 Some(cached_hint) = inlay_hint_cache.hint_by_id(excerpt_id, hovered_inlay.id)
|
||||||
|
{
|
||||||
// Check if we should process this hint for hover
|
// Check if we should process this hint for hover
|
||||||
let should_process_hint = match cached_hint.resolve_state {
|
let should_process_hint = match cached_hint.resolve_state {
|
||||||
ResolveState::CanResolve(_, _) => {
|
ResolveState::CanResolve(_, _) => {
|
||||||
|
@ -402,7 +404,8 @@ pub fn update_inlay_link_and_hover_points(
|
||||||
if part.tooltip.is_some() || part.location.is_some() {
|
if part.tooltip.is_some() || part.location.is_some() {
|
||||||
// Found the meaningful part - show hover for it
|
// Found the meaningful part - show hover for it
|
||||||
let highlight_start = part_offset + extra_shift_left;
|
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 {
|
let highlight = InlayHighlight {
|
||||||
inlay: hovered_inlay.id,
|
inlay: hovered_inlay.id,
|
||||||
|
@ -451,7 +454,8 @@ pub fn update_inlay_link_and_hover_points(
|
||||||
editor,
|
editor,
|
||||||
InlayHover {
|
InlayHover {
|
||||||
tooltip: HoverBlock {
|
tooltip: HoverBlock {
|
||||||
text: "Loading documentation...".to_string(),
|
text: "Loading documentation..."
|
||||||
|
.to_string(),
|
||||||
kind: HoverBlockKind::PlainText,
|
kind: HoverBlockKind::PlainText,
|
||||||
},
|
},
|
||||||
range: highlight.clone(),
|
range: highlight.clone(),
|
||||||
|
@ -588,7 +592,8 @@ 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
|
if secondary_held
|
||||||
&& !editor.has_pending_nonempty_selection()
|
&& !editor.has_pending_nonempty_selection()
|
||||||
{
|
{
|
||||||
|
@ -619,6 +624,7 @@ pub fn update_inlay_link_and_hover_points(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !go_to_definition_updated {
|
if !go_to_definition_updated {
|
||||||
editor.hide_hovered_link(cx)
|
editor.hide_hovered_link(cx)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue