Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Do not run brace completion on empty text. (#2965)
Piotr Osiewicz1eb74acb3ecc
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex d651980f331..3f94f815f2f 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -2289,14 +2289,18 @@ impl Editor {// bracket of any of this language's bracket pairs.let mut bracket_pair = None;let mut is_bracket_pair_start = false;- for (pair, enabled) in scope.brackets() {- if enabled && pair.close && pair.start.ends_with(text.as_ref()) {- bracket_pair = Some(pair.clone());- is_bracket_pair_start = true;- break;- } else if pair.end.as_str() == text.as_ref() {- bracket_pair = Some(pair.clone());- break;+ if !text.is_empty() {+ // `text` can be empty when an user is using IME (e.g. Chinese Wubi Simplified)+ // and they are removing the character that triggered IME popup.+ for (pair, enabled) in scope.brackets() {+ if enabled && pair.close && pair.start.ends_with(text.as_ref()) {+ bracket_pair = Some(pair.clone());+ is_bracket_pair_start = true;+ break;+ } else if pair.end.as_str() == text.as_ref() {+ bracket_pair = Some(pair.clone());+ break;+ }}}