mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 05:12:06 +03:00
Properly compare previous hover trigger point when hover changes
This commit is contained in:
parent
dad64edde1
commit
693e91f335
@ -23,6 +23,7 @@ pub struct LinkGoToDefinitionState {
|
|||||||
pub task: Option<Task<Option<()>>>,
|
pub task: Option<Task<Option<()>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum GoToDefinitionTrigger {
|
pub enum GoToDefinitionTrigger {
|
||||||
Text(DisplayPoint),
|
Text(DisplayPoint),
|
||||||
InlayHint(InlayRange, lsp::Location, LanguageServerId),
|
InlayHint(InlayRange, lsp::Location, LanguageServerId),
|
||||||
@ -81,7 +82,7 @@ impl TriggerPoint {
|
|||||||
fn anchor(&self) -> &Anchor {
|
fn anchor(&self) -> &Anchor {
|
||||||
match self {
|
match self {
|
||||||
TriggerPoint::Text(anchor) => anchor,
|
TriggerPoint::Text(anchor) => anchor,
|
||||||
TriggerPoint::InlayHint(coordinates, _, _) => &coordinates.inlay_position,
|
TriggerPoint::InlayHint(range, _, _) => &range.inlay_position,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,13 +128,24 @@ pub fn update_go_to_definition_link(
|
|||||||
&trigger_point,
|
&trigger_point,
|
||||||
&editor.link_go_to_definition_state.last_trigger_point,
|
&editor.link_go_to_definition_state.last_trigger_point,
|
||||||
) {
|
) {
|
||||||
if a.anchor()
|
match (a, b) {
|
||||||
.cmp(b.anchor(), &snapshot.buffer_snapshot)
|
(TriggerPoint::Text(anchor_a), TriggerPoint::Text(anchor_b)) => {
|
||||||
|
if anchor_a.cmp(anchor_b, &snapshot.buffer_snapshot).is_eq() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(TriggerPoint::InlayHint(range_a, _, _), TriggerPoint::InlayHint(range_b, _, _)) => {
|
||||||
|
if range_a
|
||||||
|
.inlay_position
|
||||||
|
.cmp(&range_b.inlay_position, &snapshot.buffer_snapshot)
|
||||||
.is_eq()
|
.is_eq()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editor.link_go_to_definition_state.last_trigger_point = trigger_point.clone();
|
editor.link_go_to_definition_state.last_trigger_point = trigger_point.clone();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user