Change summary
crates/editor/src/editor.rs | 2 +-
crates/editor/src/editor_tests.rs | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
Detailed changes
@@ -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;
@@ -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));