Fix panic in Diagnostics (#11066)
cc @maxbrunsfeld Release Notes: - Fixed a panic in populating diagnostics
This commit is contained in:
parent
9329ef1d78
commit
e0644de90e
1 changed files with 13 additions and 8 deletions
|
@ -859,20 +859,25 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compare_diagnostics<L: language::ToOffset, R: language::ToOffset>(
|
fn compare_diagnostics(
|
||||||
lhs: &DiagnosticEntry<L>,
|
old: &DiagnosticEntry<language::Anchor>,
|
||||||
rhs: &DiagnosticEntry<R>,
|
new: &DiagnosticEntry<language::Anchor>,
|
||||||
snapshot: &language::BufferSnapshot,
|
snapshot: &language::BufferSnapshot,
|
||||||
) -> Ordering {
|
) -> Ordering {
|
||||||
lhs.range
|
use language::ToOffset;
|
||||||
|
// The old diagnostics may point to a previously open Buffer for this file.
|
||||||
|
if !old.range.start.is_valid(snapshot) {
|
||||||
|
return Ordering::Greater;
|
||||||
|
}
|
||||||
|
old.range
|
||||||
.start
|
.start
|
||||||
.to_offset(snapshot)
|
.to_offset(snapshot)
|
||||||
.cmp(&rhs.range.start.to_offset(snapshot))
|
.cmp(&new.range.start.to_offset(snapshot))
|
||||||
.then_with(|| {
|
.then_with(|| {
|
||||||
lhs.range
|
old.range
|
||||||
.end
|
.end
|
||||||
.to_offset(snapshot)
|
.to_offset(snapshot)
|
||||||
.cmp(&rhs.range.end.to_offset(snapshot))
|
.cmp(&new.range.end.to_offset(snapshot))
|
||||||
})
|
})
|
||||||
.then_with(|| lhs.diagnostic.message.cmp(&rhs.diagnostic.message))
|
.then_with(|| old.diagnostic.message.cmp(&new.diagnostic.message))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue