Skip to content

Commit

Permalink
Return an empty string for composing text when no result in zh-CN cod…
Browse files Browse the repository at this point in the history
…ebook. (#3496)
  • Loading branch information
daoshengmu authored and bluemarvin committed Jun 23, 2020
1 parent be5c288 commit 23cd7b6
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public CandidatesResult getCandidates(String aComposingText) {
tempKey = tempKey.substring(0, tempKey.length() - 1);
}
}

// We can't find available candidates, so using the composing text
// as the only item of candidates.
if (candidate.length() == 0) {
candidate.append(aComposingText);
}
words.add(new Words(syllables, code.toString(), candidate.toString()));

// Extra candidates
Expand Down Expand Up @@ -187,6 +193,11 @@ public String getComposingText(String aComposing, String aCode) {
}
}
}
// If we don't have a text code from the code book,
// just return an empty string to do composing.
if (aCode.isEmpty()) {
return "";
}
return aComposing.replaceFirst(Pattern.quote(aCode), "");
}

Expand Down

0 comments on commit 23cd7b6

Please sign in to comment.