From f03a641882673dd3f1e6a5cca0fc9a629e2485f7 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 22 Jul 2022 11:52:07 +0800 Subject: [PATCH] UnitTests // Sync changes from LMAssociates. --- vChewingTests/KeyHandlerTestsSCPCCHT.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vChewingTests/KeyHandlerTestsSCPCCHT.swift b/vChewingTests/KeyHandlerTestsSCPCCHT.swift index 25cb3747..5753ccd2 100644 --- a/vChewingTests/KeyHandlerTestsSCPCCHT.swift +++ b/vChewingTests/KeyHandlerTestsSCPCCHT.swift @@ -357,13 +357,15 @@ extension String { extension vChewing.LMAssociates { public mutating func forceOpenStringInstead(_ strData: String) { - strData.ranges(splitBy: "\n").forEach { + strData.ranges(splitBy: "\n").filter({ !$0.isEmpty }).forEach { let neta = strData[$0].split(separator: " ") if neta.count >= 2 { let theKey = String(neta[0]) - if !neta[0].isEmpty, !neta[1].isEmpty, theKey.first != "#" { - let theValue = $0 - rangeMap[theKey, default: []].append(theValue) + if !theKey.isEmpty, theKey.first != "#" { + for (i, _) in neta.filter({ $0.first != "#" && !$0.isEmpty }).enumerated() { + if i == 0 { continue } + rangeMap[theKey, default: []].append(($0, i)) + } } } }