From 6fa6e0718cf808b14de545aafe95f08d0ef60a3b Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 7 Jun 2024 11:48:23 -0600 Subject: [PATCH] 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 --- crates/diagnostics/src/diagnostics.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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)