Skip to content

Commit 40261f3

Browse files
committed
Remove prefix matches that duplicate exact matches
Fixes <#19>.
1 parent fe47784 commit 40261f3

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

app/src/main/java/io/github/yawnoc/strokeinput/StrokeInputService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,17 +864,20 @@ private List<String> computeCandidateList(final String strokeDigitSequence)
864864

865865
updateCandidateOrderPreference();
866866

867+
final Set<Integer> exactMatchCodePointSet;
867868
final List<String> exactMatchCandidateList;
868869
final String exactMatchCharacters = charactersFromStrokeDigitSequence.get(strokeDigitSequence);
869870
if (exactMatchCharacters != null)
870871
{
872+
exactMatchCodePointSet = Stringy.toCodePointSet(exactMatchCharacters);
871873
exactMatchCandidateList = Stringy.toCharacterList(exactMatchCharacters);
872874
exactMatchCandidateList.sort(
873875
candidateComparator(unpreferredCodePointSet, sortingRankFromCodePoint, phraseCompletionFirstCodePointList)
874876
);
875877
}
876878
else
877879
{
880+
exactMatchCodePointSet = Collections.emptySet();
878881
exactMatchCandidateList = Collections.emptyList();
879882
}
880883

@@ -888,6 +891,7 @@ private List<String> computeCandidateList(final String strokeDigitSequence)
888891

889892
final Set<Integer> prefixMatchCodePointSet = Stringy.toCodePointSet(prefixMatchCharactersCollection);
890893

894+
prefixMatchCodePointSet.removeAll(exactMatchCodePointSet);
891895
if (prefixMatchCodePointSet.size() > LAG_PREVENTION_CODE_POINT_COUNT)
892896
{
893897
prefixMatchCodePointSet.retainAll(commonCodePointSet);

0 commit comments

Comments
 (0)