diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1d660db1fbc1e3910fd38f44bbc3817b1fa2d9b5..387920d81ee20d37b0f49134f01c010e3b102390 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2080,7 +2080,9 @@ impl Editor { )); continue; } - } else if let Some(region) = autoclose_region { + } + + if let Some(region) = autoclose_region { // If the selection is followed by an auto-inserted closing bracket, // then don't insert that closing bracket again; just move the selection // past the closing bracket. diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 839f804ec30a31590f3c20c5c9900eea4e0191b6..ccae9db92b7be77298a7614ff7fc4fdfff330f2d 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -3041,6 +3041,12 @@ async fn test_autoclose_pairs(cx: &mut gpui::TestAppContext) { close: false, newline: true, }, + BracketPair { + start: "\"".to_string(), + end: "\"".to_string(), + close: true, + newline: false, + }, ], autoclose_before: "})]".to_string(), ..Default::default() @@ -3161,6 +3167,13 @@ async fn test_autoclose_pairs(cx: &mut gpui::TestAppContext) { cx.set_state("«aˇ» b"); cx.update_editor(|view, cx| view.handle_input("{", cx)); cx.assert_editor_state("{«aˇ»} b"); + + // Autclose pair where the start and end characters are the same + cx.set_state("aˇ"); + cx.update_editor(|view, cx| view.handle_input("\"", cx)); + cx.assert_editor_state("a\"ˇ\""); + cx.update_editor(|view, cx| view.handle_input("\"", cx)); + cx.assert_editor_state("a\"\"ˇ"); } #[gpui::test]