mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-24 05:05:00 +00:00
feat: selection range of goto definition
This commit is contained in:
parent
f599a607cd
commit
efe07c7b4a
1 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,6 @@
|
|||
use log::debug;
|
||||
use tower_lsp::lsp_types::LocationLink;
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -81,6 +84,10 @@ impl GotoDefinitionRequest {
|
|||
let Some(id) = span.id() else {
|
||||
return None;
|
||||
};
|
||||
|
||||
let origin_selection_range =
|
||||
typst_to_lsp::range(callee_link.range(), &source, position_encoding).raw_range;
|
||||
|
||||
let span_path = world.path_for_id(id).ok()?;
|
||||
let span_source = world.source(id).ok()?;
|
||||
let offset = span_source.find(span)?;
|
||||
|
@ -89,6 +96,14 @@ impl GotoDefinitionRequest {
|
|||
|
||||
let uri = Url::from_file_path(span_path).ok()?;
|
||||
|
||||
Some(GotoDefinitionResponse::Scalar(LspLocation { uri, range }))
|
||||
let res = Some(GotoDefinitionResponse::Link(vec![LocationLink {
|
||||
origin_selection_range: Some(origin_selection_range),
|
||||
target_uri: uri,
|
||||
target_range: range,
|
||||
target_selection_range: range,
|
||||
}]));
|
||||
|
||||
debug!("goto_definition: {res:?}");
|
||||
res
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue