diff --git a/Source/Modules/ControllerModules/KeyHandler_Core.swift b/Source/Modules/ControllerModules/KeyHandler_Core.swift index 2a165eac..32aa5291 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Core.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Core.swift @@ -244,11 +244,10 @@ class KeyHandler { /// 這個過程不會傷到子陣列內部的排序。 if arrAnchors.isEmpty { return arrCandidates } - // sort the nodes, so that longer nodes (representing longer phrases) - // are placed at the top of the candidate list + // 讓更長的節錨排序靠前。 arrAnchors = arrAnchors.stableSort { $0.keyLength > $1.keyLength } - // then use the Swift trick to retrieve the candidates for each node at/crossing the cursor + // 將節錨內的候選字詞資料拓印到輸出陣列內。 for currentNodeAnchor in arrAnchors { if let currentNode = currentNodeAnchor.node { for currentCandidate in currentNode.candidates { @@ -259,6 +258,7 @@ class KeyHandler { } } } + // 決定是否根據半衰記憶模組的建議來調整候選字詞的順序。 if mgrPrefs.fetchSuggestionsFromUserOverrideModel, !mgrPrefs.useSCPCTypingMode, !fixOrder { let arrSuggestedUnigrams: [Megrez.Unigram] = fetchSuggestedCandidates().stableSort { $0.score > $1.score } let arrSuggestedCandidates: [String] = arrSuggestedUnigrams.map(\.keyValue.value) diff --git a/Source/Modules/ControllerModules/KeyHandler_HandleCandidate.swift b/Source/Modules/ControllerModules/KeyHandler_HandleCandidate.swift index 7de2b2a9..c2fc7c21 100644 --- a/Source/Modules/ControllerModules/KeyHandler_HandleCandidate.swift +++ b/Source/Modules/ControllerModules/KeyHandler_HandleCandidate.swift @@ -35,7 +35,7 @@ extension KeyHandler { /// - Parameters: /// - input: 輸入訊號。 /// - state: 給定狀態(通常為當前狀態)。 - /// - stateCallback: 狀態回呼,交給對應的型別內的專有函數來處理。 + /// - stateCallback: 狀態回呼,交給對應的型別內的專有函式來處理。 /// - errorCallback: 錯誤回呼。 /// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。 func handleCandidate( diff --git a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift index 3523d1b4..724765da 100644 --- a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift +++ b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift @@ -36,7 +36,7 @@ extension KeyHandler { /// - Parameters: /// - input: 輸入訊號。 /// - state: 給定狀態(通常為當前狀態)。 - /// - stateCallback: 狀態回呼,交給對應的型別內的專有函數來處理。 + /// - stateCallback: 狀態回呼,交給對應的型別內的專有函式來處理。 /// - errorCallback: 錯誤回呼。 /// - Returns: 告知 IMK「該按鍵是否已經被輸入法攔截處理」。 func handle(