parent
583ce44359
commit
4195f27964
2 changed files with 15 additions and 11 deletions
|
@ -7264,10 +7264,6 @@ impl Editor {
|
||||||
split: bool,
|
split: bool,
|
||||||
cx: &mut ViewContext<Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
let Some(workspace) = self.workspace() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
let pane = workspace.read(cx).active_pane().clone();
|
|
||||||
// If there is one definition, just open it directly
|
// If there is one definition, just open it directly
|
||||||
if definitions.len() == 1 {
|
if definitions.len() == 1 {
|
||||||
let definition = definitions.pop().unwrap();
|
let definition = definitions.pop().unwrap();
|
||||||
|
@ -7285,6 +7281,11 @@ impl Editor {
|
||||||
let target = target_task.await.context("target resolution task")?;
|
let target = target_task.await.context("target resolution task")?;
|
||||||
if let Some(target) = target {
|
if let Some(target) = target {
|
||||||
editor.update(&mut cx, |editor, cx| {
|
editor.update(&mut cx, |editor, cx| {
|
||||||
|
let Some(workspace) = editor.workspace() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let pane = workspace.read(cx).active_pane().clone();
|
||||||
|
|
||||||
let range = target.range.to_offset(target.buffer.read(cx));
|
let range = target.range.to_offset(target.buffer.read(cx));
|
||||||
let range = editor.range_for_match(&range);
|
let range = editor.range_for_match(&range);
|
||||||
if Some(&target.buffer) == editor.buffer.read(cx).as_singleton().as_ref() {
|
if Some(&target.buffer) == editor.buffer.read(cx).as_singleton().as_ref() {
|
||||||
|
@ -7325,7 +7326,7 @@ impl Editor {
|
||||||
} else if !definitions.is_empty() {
|
} else if !definitions.is_empty() {
|
||||||
let replica_id = self.replica_id(cx);
|
let replica_id = self.replica_id(cx);
|
||||||
cx.spawn(|editor, mut cx| async move {
|
cx.spawn(|editor, mut cx| async move {
|
||||||
let (title, location_tasks) = editor
|
let (title, location_tasks, workspace) = editor
|
||||||
.update(&mut cx, |editor, cx| {
|
.update(&mut cx, |editor, cx| {
|
||||||
let title = definitions
|
let title = definitions
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -7353,7 +7354,7 @@ impl Editor {
|
||||||
HoverLink::Url(_) => Task::ready(Ok(None)),
|
HoverLink::Url(_) => Task::ready(Ok(None)),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
(title, location_tasks)
|
(title, location_tasks, editor.workspace().clone())
|
||||||
})
|
})
|
||||||
.context("location tasks preparation")?;
|
.context("location tasks preparation")?;
|
||||||
|
|
||||||
|
@ -7363,6 +7364,10 @@ impl Editor {
|
||||||
.filter_map(|location| location.transpose())
|
.filter_map(|location| location.transpose())
|
||||||
.collect::<Result<_>>()
|
.collect::<Result<_>>()
|
||||||
.context("location tasks")?;
|
.context("location tasks")?;
|
||||||
|
|
||||||
|
let Some(workspace) = workspace else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
workspace
|
workspace
|
||||||
.update(&mut cx, |workspace, cx| {
|
.update(&mut cx, |workspace, cx| {
|
||||||
Self::open_locations_in_multibuffer(
|
Self::open_locations_in_multibuffer(
|
||||||
|
|
|
@ -394,10 +394,6 @@ pub fn show_link_definition(
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(project) = editor.project.clone() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
let same_kind = hovered_link_state.preferred_kind == preferred_kind
|
let same_kind = hovered_link_state.preferred_kind == preferred_kind
|
||||||
|| hovered_link_state
|
|| hovered_link_state
|
||||||
.links
|
.links
|
||||||
|
@ -419,6 +415,7 @@ pub fn show_link_definition(
|
||||||
} else {
|
} else {
|
||||||
editor.hide_hovered_link(cx)
|
editor.hide_hovered_link(cx)
|
||||||
}
|
}
|
||||||
|
let project = editor.project.clone();
|
||||||
|
|
||||||
let snapshot = snapshot.buffer_snapshot.clone();
|
let snapshot = snapshot.buffer_snapshot.clone();
|
||||||
hovered_link_state.task = Some(cx.spawn(|this, mut cx| {
|
hovered_link_state.task = Some(cx.spawn(|this, mut cx| {
|
||||||
|
@ -436,7 +433,7 @@ pub fn show_link_definition(
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
} else {
|
} else if let Some(project) = project {
|
||||||
// query the LSP for definition info
|
// query the LSP for definition info
|
||||||
project
|
project
|
||||||
.update(&mut cx, |project, cx| match preferred_kind {
|
.update(&mut cx, |project, cx| match preferred_kind {
|
||||||
|
@ -468,6 +465,8 @@ pub fn show_link_definition(
|
||||||
definition_result.into_iter().map(HoverLink::Text).collect(),
|
definition_result.into_iter().map(HoverLink::Text).collect(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TriggerPoint::InlayHint(highlight, lsp_location, server_id) => Some((
|
TriggerPoint::InlayHint(highlight, lsp_location, server_id) => Some((
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue