From 03236671af21245dde436f042f1350e5e2330865 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 25 Oct 2022 10:32:56 +0800 Subject: [PATCH] SessionCtl // Sort lookup results according to their candidate amounts. --- Source/Modules/SessionCtl_Delegates.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Modules/SessionCtl_Delegates.swift b/Source/Modules/SessionCtl_Delegates.swift index 939c3d25..0d51d5e4 100644 --- a/Source/Modules/SessionCtl_Delegates.swift +++ b/Source/Modules/SessionCtl_Delegates.swift @@ -68,7 +68,10 @@ extension SessionCtl: CtlCandidateDelegate { if value.isEmpty { return blankResult } // 空字串沒有需要反查的東西。 if value.contains("_") { return blankResult } guard let lookupResult = LMMgr.currentLM.currentCassette.reverseLookupMap[value] else { return blankResult } - return lookupResult.stableSort(by: { $0.count < $1.count }) + return lookupResult.stableSort(by: { $0.count < $1.count }).stableSort { + LMMgr.currentLM.currentCassette.unigramsFor(key: $0).count + < LMMgr.currentLM.currentCassette.unigramsFor(key: $1).count + } } public var selectionKeys: String {