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.

Fix panic in autoclosing (#21482)

Conrad Irwin492ca219d34e
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 1e47eb46a89..88919f9295f 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -4098,8 +4098,10 @@ impl Editor {
if buffer.contains_str_at(selection.start, &pair.end) {
let pair_start_len = pair.start.len();
- if buffer.contains_str_at(selection.start - pair_start_len, &pair.start)
- {
+ if buffer.contains_str_at(
+ selection.start.saturating_sub(pair_start_len),
+ &pair.start,
+ ) {
selection.start -= pair_start_len;
selection.end += pair.end.len();