fix: don't panic on F13–F24 function keys#333
Merged
Conversation
crossterm emits KeyCode::F(n) up to n=24, but Key::from_f only mapped F0-F12 and panicked on anything higher, crashing the whole TUI when an unmapped function key (e.g. F24 from a global hotkey) reached it. Map the unmapped range to the existing Key::Unknown catch-all instead. Fixes LargeModGames#332
Owner
|
this will be added in v0.40.2 as i just started the CD workflow for v0.40.1, sorry about that |
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.
Summary
Pressing a function key above F12 (F13–F24) crashed the whole TUI.
Key::from_fonly mapped F0–F12 and panicked on anything higher, but crossterm emitsKeyCode::F(n)up ton = 24. Every function key is routed throughfrom_f, so an unmapped one — e.g. F24 triggered by a global hotkey while spotatui is focused — took the app down.This maps the unmapped range to the existing
Key::Unknowncatch-all so unhandled function keys are ignored like any other unbound key. spotatui binds nothing to F13–F24, so no new enum variants are needed.Changes
src/tui/event/key.rs:from_freturnsKey::Unknownforn > 12instead ofpanic!; dropped the now-inaccurate# Panicsdoc line.Testing
cargo fmt --allcargo clippy --no-default-features --features telemetry -- -D warningscargo test --no-default-features --features telemetry(326 passed)Fixes #332