SessionCtl // Trim newlines among lookup results.

This commit is contained in:
ShikiSuen 2022-10-26 10:10:56 +08:00
parent 86512eb625
commit e35a5b246f
1 changed files with 4 additions and 1 deletions

View File

@ -67,7 +67,10 @@ extension SessionCtl: CtlCandidateDelegate {
if isVerticalTyping { return blankResult } //
if value.isEmpty { return blankResult } // 西
if value.contains("_") { return blankResult }
guard let lookupResult = LMMgr.currentLM.currentCassette.reverseLookupMap[value] else { return blankResult }
guard var lookupResult = LMMgr.currentLM.currentCassette.reverseLookupMap[value] else { return blankResult }
for i in 0..<lookupResult.count {
lookupResult[i] = lookupResult[i].trimmingCharacters(in: .newlines)
}
return lookupResult.stableSort(by: { $0.count < $1.count }).stableSort {
LMMgr.currentLM.currentCassette.unigramsFor(key: $0).count
< LMMgr.currentLM.currentCassette.unigramsFor(key: $1).count