From 3bd8da529fe9b74e0380cb433f2574fa318a3074 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 8 Apr 2022 14:08:43 +0800 Subject: [PATCH] IME // +RangeReplaceableCollection <- ctlPrefWindow. --- Source/Modules/IMEModules/IME.swift | 11 +++++++++++ Source/WindowControllers/ctlPrefWindow.swift | 8 -------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Source/Modules/IMEModules/IME.swift b/Source/Modules/IMEModules/IME.swift index 2e60ec79..6ac4a888 100644 --- a/Source/Modules/IMEModules/IME.swift +++ b/Source/Modules/IMEModules/IME.swift @@ -225,3 +225,14 @@ import Cocoa } } + +// MARK: - Root Extensions + +// Extend the RangeReplaceableCollection to allow it clean duplicated characters. +// Ref: https://stackoverflow.com/questions/25738817/ +extension RangeReplaceableCollection where Element: Hashable { + var charDeDuplicate: Self { + var set = Set() + return filter { set.insert($0).inserted } + } +} diff --git a/Source/WindowControllers/ctlPrefWindow.swift b/Source/WindowControllers/ctlPrefWindow.swift index 061aa472..aea18141 100644 --- a/Source/WindowControllers/ctlPrefWindow.swift +++ b/Source/WindowControllers/ctlPrefWindow.swift @@ -27,14 +27,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import Carbon import Cocoa -// Extend the RangeReplaceableCollection to allow it clean duplicated characters. -extension RangeReplaceableCollection where Element: Hashable { - var charDeDuplicate: Self { - var set = Set() - return filter { set.insert($0).inserted } - } -} - // Please note that the class should be exposed using the same class name // in Objective-C in order to let IMK to see the same class name as // the "InputMethodServerPreferencesWindowControllerClass" in Info.plist.