Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Crash sooner on invalid background highlights (#7702)

Conrad Irwind13a731cd6b2
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index a864204dc84..cfd8cfafcd2 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<Self>,
) {
+ let snapshot = self.snapshot(cx);
+ // this is to try and catch a panic sooner
+ for range in &ranges {
+ snapshot
+ .buffer_snapshot
+ .summary_for_anchor::<usize>(&range.start);
+ snapshot
+ .buffer_snapshot
+ .summary_for_anchor::<usize>(&range.end);
+ }
+
self.background_highlights
.insert(TypeId::of::<T>(), (color_fetcher, ranges));
cx.notify();