diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 4d8162972326eec7fbcf8361ba782e48de03e4f1..4b8c943dd098fd2589d0c2a58408f57a27650713 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -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)