search/filter_kanji: keep order when deduplicating
All checks were successful
Build and test / evals (push) Successful in 13m33s

This commit is contained in:
2026-03-02 17:37:45 +09:00
parent bb44bf786a
commit d14e3909d4
2 changed files with 32 additions and 1 deletions

View File

@@ -18,7 +18,15 @@ Future<List<String>> filterKanjiWithDbConnection(
.then((value) => value.map((e) => e['literal'] as String).toSet());
if (deduplicate) {
return filteredKanji.toList();
final List<String> result = [];
final Set<String> seen = {};
for (final k in kanji) {
if (filteredKanji.contains(k) && !seen.contains(k)) {
result.add(k);
seen.add(k);
}
}
return result;
} else {
return kanji.where((k) => filteredKanji.contains(k)).toList();
}