From 780360abf078d47908c446941bc0c0bae6b8664d Mon Sep 17 00:00:00 2001 From: slotThe Date: Tue, 6 Apr 2021 18:33:34 +0200 Subject: [PATCH] X.Prompt: Special handling of one highlighted item Fixes a bug introduced in f2cfaa33980061f4fb39b689403701d36babe33f. 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. --- XMonad/Prompt.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/XMonad/Prompt.hs b/XMonad/Prompt.hs index b60a96da..189ffa74 100644 --- a/XMonad/Prompt.hs +++ b/XMonad/Prompt.hs @@ -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