Skip to content

fix(cinbase): make Shift language switching reliable (#1044) - #1049

Merged
PCMan merged 2 commits into
masterfrom
fix/cinbase-shift-switch-1044
Nov 21, 2026
Merged

PCMan merged 2 commits into
masterfrom
fix/cinbase-shift-switch-1044

Conversation

@PCMan

@PCMan PCMan commented Nov 20, 2026

Copy link
Copy Markdown
Member

Fixes #1044

  • Record cbTS.lastKeyEvent in filterKeyDown() and check lastKeyEvent.isKeyDown(VK_LSHIFT / VK_RSHIFT) in isPressed() instead of calling GetAsyncKeyState() from the background Python process on KeyUp.
  • Toggle language mode (toggleLanguageMode()) directly inside filterKeyUp(), and only set isLangModeChanged = True (requesting onKeyUp()) when an EditSession is needed to show prompt messages or clear active composition/candidates.
  • Refresh lastKeyDownTime when a different key is pressed (while preserving it across held-key auto-repeat) and reset key-tracking state in onDeactivate() and onPreservedKey().
  • Add unit tests in tests/test_cinbase_shift_switch.py.

Calling GetAsyncKeyState() on KeyUp across IPC is racy and unreliable for distinguishing Left/Right Shift (matching the issue previously fixed in chewing). Deferring toggleLanguageMode() to onKeyUp() also fails whenever TSF skips OnKeyUp or cannot grant a synchronous read-write EditSession, and stale lastKeyDownTime values after missed KeyUp events caused valid Shift taps to exceed the 0.5s threshold.

Fully generated by Google Antigravity (Gemini 4 Neon) without human intervention.

- Record cbTS.lastKeyEvent on filterKeyDown and check lastKeyEvent.isKeyDown(VK_LSHIFT/VK_RSHIFT) in isPressed() instead of calling GetAsyncKeyState() from the background Python process on KeyUp.
- Toggle language mode directly inside filterKeyUp() and only request onKeyUp() (via isLangModeChanged) when an EditSession is needed for prompt messages or clearing active composition/candidates.
- Refresh lastKeyDownTime when a different key is pressed and clear key-tracking state in onDeactivate() and onPreservedKey() so missed KeyUp events cannot leave a stale timestamp.
- Add unit tests in tests/test_cinbase_shift_switch.py.

Calling GetAsyncKeyState() on KeyUp across IPC is racy and unreliable for distinguishing Left/Right Shift, and deferring toggleLanguageMode() to onKeyUp() fails whenever TSF does not grant a synchronous edit session or skips OnKeyUp. Stale lastKeyDownTime after focus changes or preserved keys also caused valid Shift taps to exceed the 0.5s threshold.

Fully generated by Google Antigravity (Gemini 4 Neon) without human intervention.
…eyEvent

Use cbTS.lastKeyEvent.keyCode directly instead of maintaining a separate cbTS.lastKeyDownCode field, avoiding duplicate state that could drift out of sync.

Fully generated by Google Antigravity (Gemini 4 Neon) without human intervention.
@PCMan
PCMan force-pushed the fix/cinbase-shift-switch-1044 branch from 6b67735 to ee56eb4 Compare November 21, 2026 04:53
@PCMan
PCMan merged commit f8a3038 into master Nov 21, 2026
4 of 6 checks passed
@PCMan
PCMan deleted the fix/cinbase-shift-switch-1044 branch November 21, 2026 05:32
@PCMan

PCMan commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Tested,

asdf80730 added a commit to asdf80730/PIME that referenced this pull request Nov 22, 2026
Upstream cut v2.0.0-beta6 at 1911328 on 2026-11-21: EasyIME#1043 config-tool token
check, EasyIME#1049 the cinbase Shift key-up path (EasyIME#1044), EasyIME#1009 and EasyIME#1050 the Go
backend imports and optional build, EasyIME#1051 the Rime auto-deploy, EasyIME#1052 the
SignPath wait, and the version.txt bump. No feat(...) landed, so the 2026-11-13
"v2.0 first" adjudication still holds.

Conflict resolutions:

- go-backend/server.go keeps the local side, which is a superset: the guids
  loop and the "rime", "rime-cn" case (ADR 0004) over upstream's single guid.
- go-backend/server_integration_test.go takes upstream's close-notification test.
- python/cinbase/__init__.py takes upstream's lastKeyEvent key-up path, with the
  local shiftTapCount loop kept so N taps still toggle N times; the local
  shiftTapMatches now passes cbTS to isPressed for its per-side check.
- python/input_methods/rime/rime_ime.py stays the thin wrapper; upstream's
  needs_rime_deploy and fullcheck land in python/rimebase/rime_service.py and
  are re-exported by both profile wrappers, and tests/test_rime_deploy.py is
  re-pointed at that module pair.

docs/tour/index.html and the maintainer-plan record now read against 1911328.

Fully generated by omp (Qwen3.8-Flash-Next) without human intervention.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2.0.0-beta4 使用酷倉時shift無效

1 participant