Skip to content

Commit

Permalink
Merge pull request #850 from slotThe/fix/prompt-ignores-left
Browse files Browse the repository at this point in the history
X.Prompt: Execute keypress when it has an action associated to it
  • Loading branch information
slotThe authored Dec 17, 2023
2 parents 5c30cad + 00993d4 commit e75eb16
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions XMonad/Prompt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -708,25 +708,28 @@ handleMain stroke@(keysym, keystr) = \case
getCurrentCompletions >>= handleCompletionMain Next
| (keymask, keysym) == prevCompKey ->
getCurrentCompletions >>= handleCompletionMain Prev
| otherwise -> unless (isModifier stroke) $ do
setCurrentCompletions Nothing
if keysym == modeKey
then modify setNextMode >> updateWindows
else handleInput keymask
| otherwise -> do
keymap <- gets (promptKeymap . config)
let mbAction = M.lookup (keymask, keysym) keymap
-- Either run when we can insert a valid character, or the
-- 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
where
-- Prompt input handler for the main loop.
handleInput :: KeyMask -> XP ()
handleInput keymask = do
keymap <- gets (promptKeymap . config)
case M.lookup (keymask,keysym) keymap of
Just action -> action >> updateWindows
Nothing -> when (keymask .&. controlMask == 0) $ do
insertString $ utf8Decode keystr
updateWindows
updateHighlightedCompl
complete <- tryAutoComplete
when complete acceptSelection
handleInput :: KeyMask -> Maybe (XP ()) -> XP ()
handleInput keymask = \case
Just action -> action >> updateWindows
Nothing -> when (keymask .&. controlMask == 0) $ do
insertString $ utf8Decode keystr
updateWindows
updateHighlightedCompl
complete <- tryAutoComplete
when complete acceptSelection

-- There are two options to store the completion list during the main loop:
-- * Use the State monad, with 'Nothing' as the initial state.
Expand Down

0 comments on commit e75eb16

Please sign in to comment.