Crash sooner on invalid background highlights (#7702)

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-02-12 14:44:10 -07:00 committed by GitHub
parent ede9600ab4
commit d13a731cd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();