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,5 +1,7 @@
//! <https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#on-enter>
use typst_shim::syntax::LinkedNodeExt;
use crate::{prelude::*, SyntaxRequest};
/// The [`experimental/onEnter`] request is sent from client to server to handle
@ -32,7 +34,7 @@ impl SyntaxRequest for OnEnterRequest {
) -> Option<Self::Response> {
let root = LinkedNode::new(source.root());
let cursor = lsp_to_typst::position(self.position, position_encoding, source)?;
let leaf = root.leaf_at(cursor)?;
let leaf = root.leaf_at_compat(cursor)?;
let worker = OnEnterWorker {
source,