summaryrefslogtreecommitdiff
path: root/support/texlab/crates/texlab/src/features/highlight.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/texlab/src/features/highlight.rs')
-rw-r--r--support/texlab/crates/texlab/src/features/highlight.rs24
1 files changed, 6 insertions, 18 deletions
diff --git a/support/texlab/crates/texlab/src/features/highlight.rs b/support/texlab/crates/texlab/src/features/highlight.rs
index 10c5d95fb1..4706e3964e 100644
--- a/support/texlab/crates/texlab/src/features/highlight.rs
+++ b/support/texlab/crates/texlab/src/features/highlight.rs
@@ -1,27 +1,15 @@
-use base_db::{FeatureParams, Workspace};
-use highlights::{HighlightKind, HighlightParams};
+use base_db::Workspace;
-use crate::util::line_index_ext::LineIndexExt;
+use crate::util::{from_proto, to_proto};
pub fn find_all(
workspace: &Workspace,
- params: &lsp_types::DocumentHighlightParams,
+ params: lsp_types::DocumentHighlightParams,
) -> Option<Vec<lsp_types::DocumentHighlight>> {
- let uri = &params.text_document_position_params.text_document.uri;
- let document = workspace.lookup(uri)?;
- let position = params.text_document_position_params.position;
- let offset = document.line_index.offset_lsp(position)?;
- let feature = FeatureParams::new(workspace, document);
- let params = HighlightParams { feature, offset };
- let results = highlights::find_all(params);
+ let params = from_proto::highlight_params(workspace, params)?;
+ let results = highlights::find_all(&params);
let results = results.into_iter().filter_map(|result| {
- let range = document.line_index.line_col_lsp_range(result.range)?;
- let kind = Some(match result.kind {
- HighlightKind::Write => lsp_types::DocumentHighlightKind::WRITE,
- HighlightKind::Read => lsp_types::DocumentHighlightKind::READ,
- });
-
- Some(lsp_types::DocumentHighlight { range, kind })
+ to_proto::document_highlight(result, &params.feature.document.line_index)
});
Some(results.collect())