Skip to content

fix: don't panic on F13–F24 function keys#333

Merged
LargeModGames merged 1 commit into
LargeModGames:mainfrom
Ritze03:fix/fkey-panic
Jul 4, 2026
Merged

fix: don't panic on F13–F24 function keys#333
LargeModGames merged 1 commit into
LargeModGames:mainfrom
Ritze03:fix/fkey-panic

Conversation

@Ritze03

@Ritze03 Ritze03 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Pressing a function key above F12 (F13–F24) crashed the whole TUI. Key::from_f only mapped F0–F12 and panicked on anything higher, but crossterm emits KeyCode::F(n) up to n = 24. Every function key is routed through from_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::Unknown catch-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_f returns Key::Unknown for n > 12 instead of panic!; dropped the now-inaccurate # Panics doc line.

Testing

  • cargo fmt --all
  • cargo clippy --no-default-features --features telemetry -- -D warnings
  • cargo test --no-default-features --features telemetry (326 passed)

Fixes #332

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
@LargeModGames LargeModGames merged commit 57f7a15 into LargeModGames:main Jul 4, 2026
11 checks passed
@LargeModGames

Copy link
Copy Markdown
Owner

this will be added in v0.40.2 as i just started the CD workflow for v0.40.1, sorry about that

@Ritze03 Ritze03 deleted the fix/fkey-panic branch July 4, 2026 18:18
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.

F13–F24 function keys panic the app (key.rs from_f)

2 participants