refactor: add compatibility for typst_syntax::LinkedNode.leaf_at (#582)

* refactor: add compatibility for `typst_syntax::LinkedNode.leaf_at`

* feat: `LinkedNodeExt` trait with `leaf_at_compat`
This commit is contained in:
ParaN3xus 2024-09-08 22:10:01 +08:00 committed by GitHub
parent ffa12bc2c9
commit ce107efc7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 86 additions and 28 deletions

View file

@ -1,3 +1,5 @@
use typst_shim::syntax::LinkedNodeExt;
use crate::{prelude::*, SyntaxRequest};
/// The [`textDocument/selectionRange`] request is sent from the client to the
@ -34,7 +36,7 @@ impl SyntaxRequest for 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 + 1)?;
let leaf = tree.leaf_at_compat(typst_offset + 1)?;
ranges.push(range_for_node(source, position_encoding, &leaf));
}