Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Handle autoclose when composing text (#7611)
Thorsten Ball775bce3e1a39
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 499b7ce28f1..c49a5c8c50c 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -2490,7 +2490,12 @@ impl Editor {let had_active_copilot_suggestion = this.has_active_copilot_suggestion(cx);this.change_selections(Some(Autoscroll::fit()), cx, |s| s.select(new_selections));- if !brace_inserted && EditorSettings::get_global(cx).use_on_type_format {+ 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 let Some(on_type_format_task) =this.trigger_on_type_formatting(text.to_string(), cx){@@ -9695,6 +9700,7 @@ impl ViewInputHandler for Editor {this.change_selections(None, cx, |selections| {selections.select_ranges(new_selected_ranges)});+ this.backspace(&Default::default(), cx);}this.handle_input(text, cx);@@ -9797,7 +9803,11 @@ impl ViewInputHandler for Editor {);}+ // Disable auto-closing when composing text (i.e. typing a `"` on a Brazilian keyboard)+ let use_autoclose = this.use_autoclose;+ this.set_use_autoclose(false);this.handle_input(text, cx);+ this.set_use_autoclose(use_autoclose);if let Some(new_selected_range) = new_selected_range_utf16 {let snapshot = this.buffer.read(cx).read(cx);