diff --git a/crates/tinymist-query/src/hover.rs b/crates/tinymist-query/src/hover.rs index 5260bf3b..0a655924 100644 --- a/crates/tinymist-query/src/hover.rs +++ b/crates/tinymist-query/src/hover.rs @@ -18,7 +18,7 @@ impl HoverRequest { let typst_tooltip = typst_ide::tooltip(world, doc.as_deref(), &source, typst_offset)?; - let ast_node = LinkedNode::new(source.root()).leaf_at(typst_offset)?; + let ast_node = LinkedNode::new(source.root()).leaf_at(typst_offset + 1)?; let range = typst_to_lsp::range(ast_node.range(), &source, position_encoding); Some(Hover { diff --git a/crates/tinymist-query/src/selection_range.rs b/crates/tinymist-query/src/selection_range.rs index e10cbce8..06aa2b47 100644 --- a/crates/tinymist-query/src/selection_range.rs +++ b/crates/tinymist-query/src/selection_range.rs @@ -16,7 +16,7 @@ impl SelectionRangeRequest { for position in self.positions { let typst_offset = lsp_to_typst::position(position, position_encoding, &source)?; let tree = LinkedNode::new(source.root()); - let leaf = tree.leaf_at(typst_offset)?; + let leaf = tree.leaf_at(typst_offset + 1)?; ranges.push(range_for_node(&source, position_encoding, &leaf)); } diff --git a/crates/tinymist-query/src/signature_help.rs b/crates/tinymist-query/src/signature_help.rs index 149a1a04..8a4efc9b 100644 --- a/crates/tinymist-query/src/signature_help.rs +++ b/crates/tinymist-query/src/signature_help.rs @@ -15,7 +15,7 @@ impl SignatureHelpRequest { let source = get_suitable_source_in_workspace(world, &self.path).ok()?; let typst_offset = lsp_to_typst::position(self.position, position_encoding, &source)?; - let ast_node = LinkedNode::new(source.root()).leaf_at(typst_offset)?; + let ast_node = LinkedNode::new(source.root()).leaf_at(typst_offset + 1)?; let (callee, callee_node, args) = surrounding_function_syntax(&ast_node)?; if !callee.hash() && !matches!(callee, ast::Expr::MathIdent(_)) {