1
0
mirror of https://github.com/xmonad/xmonad-contrib.git synced 2025-08-14 19:55:55 -07:00

X.Prompt: Special handling of one highlighted item

Fixes a bug introduced in f2cfaa3398.

The changes there allowed the prompt to cycle through its input; it now
becomes necessary to single out the case of only having a single
suggestion that's also highlighted.  Otherwise, `hlComplete` (condition:
`alwaysHighlight` is enabled) will loop forever.  This case can't be
handled from within hlComplete, as we are giving it incomplete
information to start with (by only calling it with the last word of the
current completion in `handleCompletion`), which is necessary for things
like completing arguments.
This commit is contained in:
slotThe
2021-04-06 18:33:34 +02:00
parent 78b6df0e69
commit 780360abf0

@@ -410,9 +410,10 @@ highlightedItem st' completions = case complWinDim st' of
(_,_,_,_,xx,yy) = winDim
complMatrix = splitInSubListsAt (length yy) (take (length xx * length yy) completions)
(col_index,row_index) = complIndex st'
in case completions of
[] -> Nothing
_ -> complMatrix !? col_index >>= (!? row_index)
in case length completions of
0 -> Nothing
1 -> Just $ complMatrix !! col_index !! row_index
_ -> complMatrix !? col_index >>= (!? row_index)
where
-- | Safe version of '(!!)'.
(!?) :: [a] -> Int -> Maybe a