fix: source switch on primary node

This commit is contained in:
Myriad-Dreamin 2024-03-08 17:06:08 +08:00
parent efe07c7b4a
commit f6d473f320
3 changed files with 61 additions and 8 deletions

View file

@ -1,6 +1,7 @@
use std::{borrow::Cow, ops::Range};
use comemo::Prehashed;
use log::debug;
use tower_lsp::lsp_types::{InlayHintKind, InlayHintLabel};
use typst::{
foundations::{Args, Closure},
@ -32,7 +33,15 @@ impl InlayHintRequest {
);
let hints = inlay_hints(world, &source, range, position_encoding).ok()?;
trace!("got inlay hints {hints:?}");
debug!(
"got inlay hints on {source:?} => {hints:?}",
source = source.id(),
hints = hints.len()
);
if hints.is_empty() {
let root = LinkedNode::new(source.root());
debug!("debug root {root:#?}");
}
Some(hints)
}

View file

@ -57,6 +57,24 @@ mod polymorphic {
FoldingRange(FoldingRangeRequest),
SelectionRange(SelectionRangeRequest),
}
impl CompilerQueryRequest {
pub fn associated_path(&self) -> Option<&Path> {
Some(match self {
CompilerQueryRequest::OnSaveExport(req) => &req.path,
CompilerQueryRequest::Hover(req) => &req.path,
CompilerQueryRequest::GotoDefinition(req) => &req.path,
CompilerQueryRequest::InlayHint(req) => &req.path,
CompilerQueryRequest::Completion(req) => &req.path,
CompilerQueryRequest::SignatureHelp(req) => &req.path,
CompilerQueryRequest::DocumentSymbol(req) => &req.path,
CompilerQueryRequest::Symbol(..) => return None,
CompilerQueryRequest::SemanticTokensFull(req) => &req.path,
CompilerQueryRequest::SemanticTokensDelta(req) => &req.path,
CompilerQueryRequest::FoldingRange(req) => &req.path,
CompilerQueryRequest::SelectionRange(req) => &req.path,
})
}
}
#[derive(Debug, Clone)]
pub enum CompilerQueryResponse {