diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 601d0d47a5a763f4cc786a50aa80289a217df3a4..1e61dc9f4a255a242f112841f477b0d9fed3b93b 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2819,6 +2819,9 @@ impl Editor { } if let Some(bracket_pair) = bracket_pair { + let autoclose = self.use_autoclose + && snapshot.settings_at(selection.start, cx).use_autoclose; + if selection.is_empty() { if is_bracket_pair_start { let prefix_len = bracket_pair.start.len() - text.len(); @@ -2839,8 +2842,6 @@ impl Editor { ), &bracket_pair.start[..prefix_len], )); - let autoclose = self.use_autoclose - && snapshot.settings_at(selection.start, cx).use_autoclose; if autoclose && following_text_allows_autoclose && preceding_text_matches_prefix @@ -2893,7 +2894,10 @@ impl Editor { } // If an opening bracket is 1 character long and is typed while // text is selected, then surround that text with the bracket pair. - else if is_bracket_pair_start && bracket_pair.start.chars().count() == 1 { + else if autoclose + && is_bracket_pair_start + && bracket_pair.start.chars().count() == 1 + { edits.push((selection.start..selection.start, text.clone())); edits.push(( selection.end..selection.end, @@ -3016,12 +3020,7 @@ impl Editor { s.select(new_selections) }); - if brace_inserted { - // If we inserted a brace while composing text (i.e. typing `"` on a - // Brazilian keyboard), exit the composing state because most likely - // the user wanted to surround the selection. - this.unmark_text(cx); - } else if EditorSettings::get_global(cx).use_on_type_format { + if !brace_inserted && EditorSettings::get_global(cx).use_on_type_format { if let Some(on_type_format_task) = this.trigger_on_type_formatting(text.to_string(), cx) {