Merge pull request #505 from slotThe/hl-item

X.Prompt: Special handling of one highlighted item
This commit is contained in:
slotThe
2021-04-07 15:26:56 +02:00
committed by GitHub

View File

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