tui: Fix Shift+Tab kline sampling reverse cycle - #314
Merged
Conversation
crossterm 0.29 reports CSI Z (Shift+Tab on foot, xterm, and similar terminals) as BackTab with the SHIFT modifier. The keymap bound BackTab with no modifiers and compared chords exactly, so Shift+Tab never dispatched ActionId::BackTab and kline sampling could only move forward. Fold BackTab+SHIFT, Tab+SHIFT, and bare BackTab onto one chord so the existing binding matches every common encoding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
?documentsTAB, Shift+TABas switching kline sampling both ways. Tab worked; Shift+Tab did nothing, on foot and any other terminal that sends CSI Z.There is no existing issue for this.
Cause
crossterm 0.29 parses CSI Z (
\e[Z, terminfokcbt) asKeyCode::BackTabwithKeyModifiers::SHIFT:The keymap bound
BackTabwithKeyModifiers::NONEand compared chords exactly.BackTab+NONEnever equalledBackTab+SHIFT, soActionId::BackTabwas never dispatched andKlineType::prev()never ran.KlineType::next()also clamps atYearrather than wrapping, so Tab cannot be used as a reverse path either.The same miss happens on xterm, kitty, alacritty, and wezterm — not only foot. Kitty's CSI-u protocol reports Shift+Tab as
Tab+SHIFT, which was also unmatched.Fix
Fold the three encodings onto one chord in
KeyChord::normalized(), the same wayGand Shift+gare already folded:BackTab+SHIFT(crossterm 0.29 / CSI Z)Tab+SHIFT(kitty keyboard protocol)BackTabwith no modifiers (older parsers)Plain Tab is unchanged and still moves sampling forward.
Checks
cargo fmtcargo clippy --bin longbridge -- -D warningscargo test --bin longbridge tui::keymap(9 tests, including the new encoding cases)