IME // charDeDuplicate -> deduplicate; +cleanup.

This commit is contained in:
ShikiSuen 2022-06-22 17:53:58 +08:00
parent 77dd885ca9
commit 40c3b3042c
3 changed files with 3 additions and 3 deletions

View File

@ -373,7 +373,7 @@ public enum IME {
// Extend the RangeReplaceableCollection to allow it clean duplicated characters. // Extend the RangeReplaceableCollection to allow it clean duplicated characters.
// Ref: https://stackoverflow.com/questions/25738817/ // Ref: https://stackoverflow.com/questions/25738817/
extension RangeReplaceableCollection where Element: Hashable { extension RangeReplaceableCollection where Element: Hashable {
var charDeDuplicate: Self { var deduplicate: Self {
var set = Set<Element>() var set = Set<Element>()
return filter { set.insert($0).inserted } return filter { set.insert($0).inserted }
} }

View File

@ -65,7 +65,7 @@ struct suiPrefPaneExperience: View {
ComboBox(items: mgrPrefs.suggestedCandidateKeys, text: $selSelectionKeys).frame(width: 180).onChange( ComboBox(items: mgrPrefs.suggestedCandidateKeys, text: $selSelectionKeys).frame(width: 180).onChange(
of: selSelectionKeys of: selSelectionKeys
) { value in ) { value in
let keys: String = (value.trimmingCharacters(in: .whitespacesAndNewlines) as String).charDeDuplicate let keys: String = value.trimmingCharacters(in: .whitespacesAndNewlines).deduplicate
do { do {
try mgrPrefs.validate(candidateKeys: keys) try mgrPrefs.validate(candidateKeys: keys)
mgrPrefs.candidateKeys = keys mgrPrefs.candidateKeys = keys

View File

@ -228,7 +228,7 @@ class ctlPrefWindow: NSWindowController {
let keys = (sender as AnyObject).stringValue?.trimmingCharacters( let keys = (sender as AnyObject).stringValue?.trimmingCharacters(
in: .whitespacesAndNewlines in: .whitespacesAndNewlines
) )
.charDeDuplicate .deduplicate
else { else {
return return
} }