From 1a672fcc280f591ef1520cf98afc318e630c1858 Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Wed, 13 Jul 2022 20:52:56 +0600 Subject: [PATCH] Avoid adding meta character suggestion twice when include English word suggestion is enabled in phonetic mode. --- src/phonetic/suggestion.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/phonetic/suggestion.rs b/src/phonetic/suggestion.rs index d2563d0..8f3c53c 100644 --- a/src/phonetic/suggestion.rs +++ b/src/phonetic/suggestion.rs @@ -184,7 +184,9 @@ impl PhoneticSuggestion { } // Include written English word if the feature is enabled and it is not included already. - if config.get_suggestion_include_english() && !typed_added { + // Avoid including meta character suggestion twice, so check `term` is not equal to the + // captured preceding characters + if config.get_suggestion_include_english() && !typed_added && term != string.preceding() { self.suggestions .push(Rank::last_ranked(term.to_string(), 3)); } @@ -381,6 +383,9 @@ mod tests { suggestion.suggestions, ["{আ}", "{🅰️}", "{আঃ}", "{া}", "{এ}", "{অ্যা}", "{অ্যাঁ}", "{a}"] ); + + suggestion.suggest("\"", &data, &mut selections, &config); + assert_eq!(suggestion.suggestions, ["\""]); } #[test]