mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
Merge pull request #18519 from ChayimFriedman2/invalid-offset
fix: Fix related documents diagnostics
This commit is contained in:
commit
ba56d9b9b5
1 changed files with 7 additions and 3 deletions
|
@ -511,12 +511,16 @@ pub(crate) fn handle_document_diagnostics(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|d| {
|
.filter_map(|d| {
|
||||||
let file = d.range.file_id;
|
let file = d.range.file_id;
|
||||||
let diagnostic = convert_diagnostic(&line_index, d);
|
|
||||||
if file == file_id {
|
if file == file_id {
|
||||||
|
let diagnostic = convert_diagnostic(&line_index, d);
|
||||||
return Some(diagnostic);
|
return Some(diagnostic);
|
||||||
}
|
}
|
||||||
if supports_related {
|
if supports_related {
|
||||||
related_documents.entry(file).or_insert_with(Vec::new).push(diagnostic);
|
let (diagnostics, line_index) = related_documents
|
||||||
|
.entry(file)
|
||||||
|
.or_insert_with(|| (Vec::new(), snap.file_line_index(file).ok()));
|
||||||
|
let diagnostic = convert_diagnostic(line_index.as_mut()?, d);
|
||||||
|
diagnostics.push(diagnostic);
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
});
|
});
|
||||||
|
@ -529,7 +533,7 @@ pub(crate) fn handle_document_diagnostics(
|
||||||
related_documents: related_documents.is_empty().not().then(|| {
|
related_documents: related_documents.is_empty().not().then(|| {
|
||||||
related_documents
|
related_documents
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(id, items)| {
|
.map(|(id, (items, _))| {
|
||||||
(
|
(
|
||||||
to_proto::url(&snap, id),
|
to_proto::url(&snap, id),
|
||||||
lsp_types::DocumentDiagnosticReportKind::Full(
|
lsp_types::DocumentDiagnosticReportKind::Full(
|
||||||
|
|
Loading…
Reference in a new issue