mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-23 12:45:04 +00:00
fix: error tolerance on external paths (#96)
This commit is contained in:
parent
76b4e91046
commit
37982a6870
1 changed files with 18 additions and 3 deletions
|
@ -30,11 +30,20 @@ fn convert_diagnostic(
|
|||
let uri;
|
||||
let lsp_range;
|
||||
if let Some((id, span)) = diagnostic_span_id(typst_diagnostic) {
|
||||
uri = Url::from_file_path(project.path_for_id(id)?).unwrap();
|
||||
uri = Url::from_file_path(project.path_for_id(id)?).map_err(|e| {
|
||||
let _: () = e;
|
||||
anyhow::anyhow!(
|
||||
"could not convert path to URI: id: {id:?}, context: {:?}",
|
||||
project.analysis.root
|
||||
)
|
||||
})?;
|
||||
let source = project.world().source(id)?;
|
||||
lsp_range = diagnostic_range(&source, span, position_encoding);
|
||||
} else {
|
||||
uri = Url::from_file_path(project.analysis.root.clone()).unwrap();
|
||||
uri = Url::from_file_path(project.analysis.root.clone()).map_err(|e| {
|
||||
let _: () = e;
|
||||
anyhow::anyhow!("could not convert path to URI: {:?}", project.analysis.root)
|
||||
})?;
|
||||
lsp_range = LspRange::default();
|
||||
};
|
||||
|
||||
|
@ -64,7 +73,13 @@ fn tracepoint_to_relatedinformation(
|
|||
position_encoding: PositionEncoding,
|
||||
) -> anyhow::Result<Option<DiagnosticRelatedInformation>> {
|
||||
if let Some(id) = tracepoint.span.id() {
|
||||
let uri = Url::from_file_path(project.path_for_id(id)?).unwrap();
|
||||
let uri = Url::from_file_path(project.path_for_id(id)?).map_err(|e| {
|
||||
let _: () = e;
|
||||
anyhow::anyhow!(
|
||||
"could not convert path to URI: id: {id:?}, context: {:?}",
|
||||
project.analysis.root
|
||||
)
|
||||
})?;
|
||||
let source = project.world().source(id)?;
|
||||
|
||||
if let Some(typst_range) = source.range(tracepoint.span) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue