From 655c9ece2decdb550192959175c9cd3cd88f26d1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 18 Oct 2023 11:16:14 -0700 Subject: [PATCH] Fix possibility of infinite loop in selections_with_autoclose_regions Previously, that method could loop forever if the editor's autoclose regions had unexpected selection ids. Co-authored-by: Piotr --- crates/editor/src/editor.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 7aca4ab98f..d755723085 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3286,8 +3286,10 @@ impl Editor { i = 0; } else if pair_state.range.start.to_offset(buffer) > range.end { break; - } else if pair_state.selection_id == selection.id { - enclosing = Some(pair_state); + } else { + if pair_state.selection_id == selection.id { + enclosing = Some(pair_state); + } i += 1; } }