Skip to content

fix(input): auto-detect DECCKM before routing CSI arrows as wheel events#280

Merged
Aaronontheweb merged 3 commits into
devfrom
fix/decckm-arrow-disambiguation
Jun 8, 2026
Merged

fix(input): auto-detect DECCKM before routing CSI arrows as wheel events#280
Aaronontheweb merged 3 commits into
devfrom
fix/decckm-arrow-disambiguation

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Owner

Summary

  • Bare CSI A/B were unconditionally treated as alternate-scroll wheel events when Kitty was inactive, assuming the terminal honored DECCKM (?1h). Terminals that ignore DECCKM (VHS, some PTY wrappers) send real arrow keys as CSI form, breaking all keyboard navigation.
  • Added DeckmConfirmed flag to TerminalModeContext. The parser sets it when it first observes an SS3 arrow key — proof the terminal honored DECCKM. CsiFunctionalDecoder only routes CSI A/B as wheel after this confirmation; until then they are keyboard arrows.
  • CSI C/D/H/F/P-S (left, right, home, end, F1-F4) now produce key events instead of being silently dropped when Kitty is off.

Fixes #279

Test plan

  • 1373 tests pass (1 new test for the DECCKM-confirmed wheel path)
  • 9 existing tests updated to reflect correct default behavior
  • Manual: VHS tape that sends Down arrow keys navigates lists correctly with PreferRawInput = true + AlternateScroll
  • Manual: real terminal (iTerm2/kitty/gnome-terminal) with DECCKM — wheel scroll still works after first arrow key press

…nts (#279)

CsiFunctionalDecoder unconditionally treated bare CSI A/B as
alternate-scroll wheel events when Kitty was inactive, assuming the
terminal honored DECCKM (?1h) and sent real arrows as SS3. Terminals
that ignore DECCKM (VHS, some PTY wrappers) keep sending arrows as
CSI form, so all arrow navigation broke silently.

Add a DeckmConfirmed flag to TerminalModeContext. The parser sets it
when it first sees an SS3 arrow key decoded as a KeyStroke — proof the
terminal honored DECCKM. CsiFunctionalDecoder only routes CSI A/B as
wheel after this confirmation; until then they are keyboard arrows.
SS3 F1-F4 (ESC O P/Q/R/S) use the SS3 encoding as a VT220 legacy
independent of DECCKM. The prior check (`ss3Input is KeyStroke`) was
too broad and would false-positive DECCKM confirmation when any SS3
key arrived, including F-keys. Narrow to arrow keys only.
@Aaronontheweb Aaronontheweb merged commit 6dd24b4 into dev Jun 8, 2026
13 checks passed
@Aaronontheweb Aaronontheweb deleted the fix/decckm-arrow-disambiguation branch June 8, 2026 17:34
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.

CsiFunctionalDecoder misinterprets arrow keys as wheel events when DECCKM is not honored

1 participant