summaryrefslogtreecommitdiff
path: root/support/texlab/crates/texlab/src/features/link.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/texlab/src/features/link.rs')
-rw-r--r--support/texlab/crates/texlab/src/features/link.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/support/texlab/crates/texlab/src/features/link.rs b/support/texlab/crates/texlab/src/features/link.rs
index b821dcf6e1..5b4de5f705 100644
--- a/support/texlab/crates/texlab/src/features/link.rs
+++ b/support/texlab/crates/texlab/src/features/link.rs
@@ -1,20 +1,16 @@
-use base_db::{FeatureParams, Workspace};
-use lsp_types::{DocumentLink, Url};
+use base_db::Workspace;
-use crate::util::line_index_ext::LineIndexExt;
+use crate::util::{from_proto, to_proto};
-pub fn find_all(workspace: &Workspace, uri: &Url) -> Option<Vec<DocumentLink>> {
- let document = workspace.lookup(uri)?;
+pub fn find_all(
+ workspace: &Workspace,
+ params: lsp_types::DocumentLinkParams,
+) -> Option<Vec<lsp_types::DocumentLink>> {
+ let params = from_proto::feature_params(workspace, params.text_document)?;
+ let links = links::find_links(&params)
+ .into_iter()
+ .filter_map(|link| to_proto::document_link(link, &params.document.line_index))
+ .collect();
- let links = links::find_links(FeatureParams::new(workspace, document)).into_iter();
- let links = links.filter_map(|link| {
- Some(lsp_types::DocumentLink {
- data: None,
- tooltip: None,
- target: Some(link.document.uri.clone()),
- range: document.line_index.line_col_lsp_range(link.range)?,
- })
- });
-
- Some(links.collect())
+ Some(links)
}