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:
2026-11-17 10:49:28 +08:00
co-authored by Claude Opus 5.5
parent ebcf554a6f
commit ec3ee4ba11
6 changed files with 56 additions and 9 deletions
+3 -1
View File
@@ -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)
}