Hold words typed with digit keys; one Tab undoes a wrong learned preference
"0 5j; " (安裝) committed "0 " at once: "0" had been learned as literal, and the space hold only considered words made of letters. Any Dachen keys now count (0 = ㄢ, 5j; = ㄓㄨㄤ). A Tab correction against a learned preference replaces it instead of stepping by one, and only the keys present at the Tab are learned, not everything typed after them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,9 @@ public final class LearnedPreferences {
|
||||
|
||||
public func record(_ keys: String, as mode: InputMode) {
|
||||
let delta = mode == .zhuyin ? 1 : -1
|
||||
weights[keys] = max(-3, min(3, (weights[keys] ?? 0) + delta))
|
||||
let old = weights[keys] ?? 0
|
||||
// A correction against what was learned replaces it, so one Tab is enough to undo it.
|
||||
weights[keys] = old * delta < 0 ? delta : max(-3, min(3, old + delta))
|
||||
onChange(weights)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user