Merge pull request #850 from slotThe/fix/prompt-ignores-left

X.Prompt: Execute keypress when it has an action associated to it
This commit is contained in:
Tony Zorman 2023-12-17 13:39:27 +01:00 committed by GitHub
commit e75eb16a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -708,25 +708,28 @@ handleMain stroke@(keysym, keystr) = \case
getCurrentCompletions >>= handleCompletionMain Next getCurrentCompletions >>= handleCompletionMain Next
| (keymask, keysym) == prevCompKey -> | (keymask, keysym) == prevCompKey ->
getCurrentCompletions >>= handleCompletionMain Prev getCurrentCompletions >>= handleCompletionMain Prev
| otherwise -> unless (isModifier stroke) $ do | otherwise -> do
setCurrentCompletions Nothing keymap <- gets (promptKeymap . config)
if keysym == modeKey let mbAction = M.lookup (keymask, keysym) keymap
then modify setNextMode >> updateWindows -- Either run when we can insert a valid character, or the
else handleInput keymask -- pressed key has an action associated to it.
unless (isModifier stroke && isNothing mbAction) $ do
setCurrentCompletions Nothing
if keysym == modeKey
then modify setNextMode >> updateWindows
else handleInput keymask mbAction
event -> handleOther stroke event event -> handleOther stroke event
where where
-- Prompt input handler for the main loop. -- Prompt input handler for the main loop.
handleInput :: KeyMask -> XP () handleInput :: KeyMask -> Maybe (XP ()) -> XP ()
handleInput keymask = do handleInput keymask = \case
keymap <- gets (promptKeymap . config) Just action -> action >> updateWindows
case M.lookup (keymask,keysym) keymap of Nothing -> when (keymask .&. controlMask == 0) $ do
Just action -> action >> updateWindows insertString $ utf8Decode keystr
Nothing -> when (keymask .&. controlMask == 0) $ do updateWindows
insertString $ utf8Decode keystr updateHighlightedCompl
updateWindows complete <- tryAutoComplete
updateHighlightedCompl when complete acceptSelection
complete <- tryAutoComplete
when complete acceptSelection
-- There are two options to store the completion list during the main loop: -- There are two options to store the completion list during the main loop:
-- * Use the State monad, with 'Nothing' as the initial state. -- * Use the State monad, with 'Nothing' as the initial state.