IME // charDeDuplicate -> deduplicate; +cleanup.
This commit is contained in:
parent
77dd885ca9
commit
40c3b3042c
|
@ -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 }
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue