Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Attempt to log error instead of crash in bracket highlighting (#32837)
Michael Sloand92d52b508c1
diff --git a/crates/editor/src/highlight_matching_bracket.rs b/crates/editor/src/highlight_matching_bracket.rsindex 778f5783e2f..e38197283d4 100644--- a/crates/editor/src/highlight_matching_bracket.rs+++ b/crates/editor/src/highlight_matching_bracket.rs@@ -19,6 +19,11 @@ pub fn refresh_matching_bracket_highlights(let snapshot = editor.snapshot(window, cx);let head = newest_selection.head();+ if head > snapshot.buffer_snapshot.len() {+ log::error!("bug: cursor offset is out of range while refreshing bracket highlights");+ return;+ }+let mut tail = head;if (editor.cursor_shape == CursorShape::Block || editor.cursor_shape == CursorShape::Hollow)&& head < snapshot.buffer_snapshot.len()