Skip to content

fix: parse CSI Z (backtab) as Shift+Tab#297

Merged
Aaronontheweb merged 2 commits into
Aaronontheweb:devfrom
st0o0:fix/backtab-csi-z
Jun 17, 2026
Merged

fix: parse CSI Z (backtab) as Shift+Tab#297
Aaronontheweb merged 2 commits into
Aaronontheweb:devfrom
st0o0:fix/backtab-csi-z

Conversation

@st0o0

@st0o0 st0o0 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Fix CSI Z (backtab / reverse tab) not being recognized as Shift+Tab. Previously, the Z final byte was not in the
functional key set, so terminals that emit ESC [ Z for Shift+Tab produced no usable input event. Now it correctly
maps to Tab with the Shift modifier.

Problem

Many terminals (xterm, GNOME Terminal, Windows Terminal in legacy mode) emit CSI Z when the user presses
Shift+Tab. Termina's CSI decoder did not recognize Z as a functional final byte, so backtab input was silently
dropped. This broke Shift+Tab navigation in pages that register it (e.g. clipboard gallery's focus cycling).

Changes

CsiFunctionalDecoder.cs — Add Z to IsFunctionalFinal, map it to ConsoleKey.Tab / TerminaKey.Tab, and attach the
Shift modifier via new FinalToModifiers / FinalToKeyModifiers helpers.

CsiFunctionalDecoderTests.cs — Three new tests: bare Z final returns Tab+Shift, same under Kitty-visible mode, and
IsFunctionalFinal('Z') returns true.

EscapeSequenceParserTests.cs — Integration test: full ESC [ Z sequence emits KeyPressed with ConsoleKey.Tab +
Shift.

Test plan

  • dotnet test — all new and existing input parser tests pass
  • Run the gallery demo, use Shift+Tab to cycle focus backward on the Clipboard page
  • Verify regular Tab still cycles forward (no regression)

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aaronontheweb Aaronontheweb merged commit 484a6d3 into Aaronontheweb:dev Jun 17, 2026
13 checks passed
@Aaronontheweb Aaronontheweb mentioned this pull request Jun 17, 2026
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 participants