Skip to content

Commit

Permalink
Avoid adding meta character suggestion twice
Browse files Browse the repository at this point in the history
when include English word suggestion is enabled in phonetic mode.
  • Loading branch information
mominul committed Jul 13, 2022
1 parent 98fba5f commit 1a672fc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/phonetic/suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -381,6 +383,9 @@ mod tests {
suggestion.suggestions,
["{আ}", "{🅰️}", "{আঃ}", "{া}", "{এ}", "{অ্যা}", "{অ্যাঁ}", "{a}"]
);

suggestion.suggest("\"", &data, &mut selections, &config);
assert_eq!(suggestion.suggestions, ["\""]);
}

#[test]
Expand Down

0 comments on commit 1a672fc

Please sign in to comment.