diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 38ca82b0d2244ed41c288e43abc4b67875107c2d..d1dfed3c85aca9bdd7a622a594b4f3fd72b4e582 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1874,7 +1874,7 @@ impl Editor { let mut bracket_pair = None; let mut is_bracket_pair_start = false; for pair in language.brackets() { - if pair.start.ends_with(text.as_ref()) { + if pair.close && pair.start.ends_with(text.as_ref()) { bracket_pair = Some(pair.clone()); is_bracket_pair_start = true; break; diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 430b9584078388f5059bdae884ca55618025619a..3525fa467631ee18385d65e2d8f9969ef70d61ae 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -3016,6 +3016,11 @@ async fn test_autoclose_pairs(cx: &mut gpui::TestAppContext) { cx.update_editor(|view, cx| view.handle_input("{", cx)); cx.assert_editor_state("{ˇa b"); + // Don't autoclose if `close` is false for the bracket pair + cx.set_state("ˇ"); + cx.update_editor(|view, cx| view.handle_input("[", cx)); + cx.assert_editor_state("[ˇ"); + // Surround with brackets if text is selected cx.set_state("«aˇ» b"); cx.update_editor(|view, cx| view.handle_input("{", cx));