Commit 56775b1
authored
fix: tap-hold-opposite-hand-release skips same-hand keys when held (#2017)
When I used the `tap-hold-opposite-hand-release` and pressed
`f`+`d` for ctrl and shift modifiers and then pressed `j`, it outputted
ctrl+d and ignored the `f`.
## Problem
`tap-hold-opposite-hand-release` with `(same-hand tap)` incorrectly
resolves as Hold when two same-hand HRM keys are pressed together
followed by an opposite-hand key.
**Reproduction:** Given left-hand HRM keys `f`→ctrl and `d`→shift, and
right-hand key `j`:
```
d:f t:5 d:d t:20 d:j t:20 u:j
```
**Expected:** `f` resolves as Tap (same-hand `d` was pressed)
**Actual:** `f` resolves as Hold(ctrl), outputting ctrl+d
## Root cause
The `-release` variant checks for both press+release in the queue
**before** checking which hand a key belongs to:
```rust
// Wait for the interrupting key's release before deciding.
let release = Event::Release(i, j);
if !queued.clone().copied().any(|q| q.event() == release) {
continue; // ← same-hand keys skipped when still held!
}
// hand check happens here, too late
```
When `f` is waiting and the queue contains `[d↓, j↓, j↑]`:
1. `d↓` — looks for `d↑` — **not found** (d still held) → `continue`
(skipped)
2. `j↓` — looks for `j↑` — **found** → opposite hand → **Hold**
The same-hand key `d` is invisible because it hasn't been released yet.
## Fix
Move the release check **after** the hand check. Only opposite-hand,
neutral, and unknown-hand keys require press+release. Same-hand keys
resolve immediately on press — matching `tap-hold-opposite-hand`
(non-release variant) behavior for same-hand decisions.
This is correct because the `-release` requirement exists to prevent
misfires on fast **cross-hand** overlaps (e.g., `f↓ j↓ f↑ j↑` should be
`fj`, not `ctrl+j`). Same-hand keys don't need this protection — they
already resolve as Tap structurally.1 parent 166551e commit 56775b1
File tree
2 files changed
+63
-19
lines changed- parser/src/cfg
- src/tests/sim_tests
2 files changed
+63
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
298 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
| |||
318 | 324 | | |
319 | 325 | | |
320 | 326 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
330 | 335 | | |
331 | 336 | | |
332 | 337 | | |
| |||
338 | 343 | | |
339 | 344 | | |
340 | 345 | | |
341 | | - | |
342 | | - | |
343 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
344 | 349 | | |
345 | 350 | | |
346 | 351 | | |
347 | 352 | | |
348 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
349 | 362 | | |
350 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
351 | 369 | | |
352 | 370 | | |
353 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
307 | 307 | | |
308 | | - | |
309 | | - | |
| 308 | + | |
| 309 | + | |
310 | 310 | | |
311 | | - | |
| 311 | + | |
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
403 | | - | |
| 403 | + | |
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
416 | 442 | | |
417 | 443 | | |
418 | 444 | | |
| |||
0 commit comments