From d13a731cd6b2a830faab76312503fc57c53fc51d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 12 Feb 2024 14:44:10 -0700 Subject: [PATCH] Crash sooner on invalid background highlights (#7702) Release Notes: - N/A --- crates/editor/src/editor.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index a864204dc844a9..cfd8cfafcd217b 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -8505,6 +8505,17 @@ impl Editor { color_fetcher: fn(&ThemeColors) -> Hsla, cx: &mut ViewContext, ) { + let snapshot = self.snapshot(cx); + // this is to try and catch a panic sooner + for range in &ranges { + snapshot + .buffer_snapshot + .summary_for_anchor::(&range.start); + snapshot + .buffer_snapshot + .summary_for_anchor::(&range.end); + } + self.background_highlights .insert(TypeId::of::(), (color_fetcher, ranges)); cx.notify();