Don't trigger Shift shortcuts while composing a command (bench 5552934)

Capital letters arrive as the Shift* keys, and the global board shortcuts
(ShiftS/F/M/A/Q) were checked before falling through to text input. Pasting or
typing a FEN after :fen therefore lost any 'Q' to the auto-queen toggle (and
would similarly eat A/F/S/M). Only ShiftM was guarded on an empty input buffer.

Gate the whole shortcut group on an empty input buffer so that while a command
is being composed every capital letter reaches the buffer as text.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-03 20:07:29 +02:00
parent 0d9ed12055
commit 95368c3dc5

View File

@@ -302,22 +302,26 @@ proc handleInput*(state: AppState, key: Key) =
if state.boardSetup.active and state.handleBoardSetupKey(key):
return
# Global shortcuts always require Shift.
if state.mode == ModeAnalysis and not state.boardSetup.active and key == Key.ShiftS:
enterBoardSetupMode(state)
return
if key == Key.ShiftF:
state.flipped = not state.flipped
return
if state.mode == ModeAnalysis and not state.boardSetup.active and state.input.buffer.len == 0 and key == Key.ShiftM:
state.beginMateFinderPrompt()
return
if key == Key.ShiftA:
state.toggleEngineArrows()
return
if key == Key.ShiftQ:
toggleAutoQueen(state)
return
# Global shortcuts always require Shift. They are only active when the
# input buffer is empty: while composing a command (e.g. typing/pasting a
# FEN after :fen) capital letters must reach the buffer as text rather than
# being swallowed as shortcuts (e.g. the 'Q' in a FEN vs. ShiftQ auto-queen).
if state.input.buffer.len == 0:
if state.mode == ModeAnalysis and not state.boardSetup.active and key == Key.ShiftS:
enterBoardSetupMode(state)
return
if key == Key.ShiftF:
state.flipped = not state.flipped
return
if state.mode == ModeAnalysis and not state.boardSetup.active and key == Key.ShiftM:
state.beginMateFinderPrompt()
return
if key == Key.ShiftA:
state.toggleEngineArrows()
return
if key == Key.ShiftQ:
toggleAutoQueen(state)
return
# Printable ASCII characters
let keyVal = key.int