Check validity of new.range too (#12781)

I'm not certain yet how it could be invalid, but we are still seeing
panics here.

Release Notes:

- Fixed a panic when opening the diagnostics view
This commit is contained in:
Conrad Irwin 2024-06-07 11:48:23 -06:00 committed by GitHub
parent 834089feb1
commit 6fa6e0718c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -867,10 +867,12 @@ fn compare_diagnostics(
snapshot: &language::BufferSnapshot,
) -> Ordering {
use language::ToOffset;
// The old diagnostics may point to a previously open Buffer for this file.
if !old.range.start.is_valid(snapshot) {
// The diagnostics may point to a previously open Buffer for this file.
if !old.range.start.is_valid(snapshot) || !new.range.start.is_valid(snapshot) {
return Ordering::Greater;
}
old.range
.start
.to_offset(snapshot)