IME // +RangeReplaceableCollection <- ctlPrefWindow.

This commit is contained in:
ShikiSuen 2022-04-08 14:08:43 +08:00
parent 2194f503a8
commit 3bd8da529f
2 changed files with 11 additions and 8 deletions

View File

@ -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<Element>()
return filter { set.insert($0).inserted }
}
}

View File

@ -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<Element>()
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.