From 40c3b3042c21313ab682d332ff01663aca3cda77 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 22 Jun 2022 17:53:58 +0800 Subject: [PATCH] IME // charDeDuplicate -> deduplicate; +cleanup. --- Source/Modules/IMEModules/IME.swift | 2 +- Source/UI/PrefUI/suiPrefPaneExperience.swift | 2 +- Source/WindowControllers/ctlPrefWindow.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/IMEModules/IME.swift b/Source/Modules/IMEModules/IME.swift index 21002a70..ca108ca4 100644 --- a/Source/Modules/IMEModules/IME.swift +++ b/Source/Modules/IMEModules/IME.swift @@ -373,7 +373,7 @@ public enum IME { // Extend the RangeReplaceableCollection to allow it clean duplicated characters. // Ref: https://stackoverflow.com/questions/25738817/ extension RangeReplaceableCollection where Element: Hashable { - var charDeDuplicate: Self { + var deduplicate: Self { var set = Set() return filter { set.insert($0).inserted } } diff --git a/Source/UI/PrefUI/suiPrefPaneExperience.swift b/Source/UI/PrefUI/suiPrefPaneExperience.swift index e288d504..e6273f1c 100644 --- a/Source/UI/PrefUI/suiPrefPaneExperience.swift +++ b/Source/UI/PrefUI/suiPrefPaneExperience.swift @@ -65,7 +65,7 @@ struct suiPrefPaneExperience: View { ComboBox(items: mgrPrefs.suggestedCandidateKeys, text: $selSelectionKeys).frame(width: 180).onChange( of: selSelectionKeys ) { value in - let keys: String = (value.trimmingCharacters(in: .whitespacesAndNewlines) as String).charDeDuplicate + let keys: String = value.trimmingCharacters(in: .whitespacesAndNewlines).deduplicate do { try mgrPrefs.validate(candidateKeys: keys) mgrPrefs.candidateKeys = keys diff --git a/Source/WindowControllers/ctlPrefWindow.swift b/Source/WindowControllers/ctlPrefWindow.swift index b73f64ff..d7de5183 100644 --- a/Source/WindowControllers/ctlPrefWindow.swift +++ b/Source/WindowControllers/ctlPrefWindow.swift @@ -228,7 +228,7 @@ class ctlPrefWindow: NSWindowController { let keys = (sender as AnyObject).stringValue?.trimmingCharacters( in: .whitespacesAndNewlines ) - .charDeDuplicate + .deduplicate else { return }