X.Prompt: get rid of MultiWayIf

Not needed anymore
This commit is contained in:
slotThe 2021-04-08 14:43:23 +02:00
parent 344ace492b
commit d7ad486a6e

View File

@ -1,6 +1,5 @@
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
@ -763,26 +762,26 @@ handleCompletion cs = do
-- --
--TODO: Scroll or paginate results --TODO: Scroll or paginate results
hlComplete :: String -> [String] -> XPState -> XP () hlComplete :: String -> [String] -> XPState -> XP ()
hlComplete prevCompl l st = hlComplete prevCompl l st
if | -- The current suggestion matches the command and is a | -- The current suggestion matches the command and is a
-- proper suffix of the last suggestion, so replace it. -- proper suffix of the last suggestion, so replace it.
isSuffixOfCmd && isProperSuffixOfLast -> replaceCompletion prevCompl isSuffixOfCmd && isProperSuffixOfLast = replaceCompletion prevCompl
| -- We only have one suggestion, so we need to be a little | -- We only have one suggestion, so we need to be a little
-- bit smart in order to avoid a loop. -- bit smart in order to avoid a loop.
length cs == 1 -> length cs == 1 =
if command st == hlCompl then put st else replaceCompletion (head cs) if command st == hlCompl then put st else replaceCompletion (head cs)
-- The current suggestion matches the command, so advance -- The current suggestion matches the command, so advance
-- to the next completion and try again. -- to the next completion and try again.
| isSuffixOfCmd -> | isSuffixOfCmd =
hlComplete hlCompl l $ st{ complIndex = complIndex' hlComplete hlCompl l $ st{ complIndex = complIndex'
, highlightedCompl = nextHlCompl , highlightedCompl = nextHlCompl
} }
-- If nothing matches at all, delete the suggestion and -- If nothing matches at all, delete the suggestion and
-- highlight the next one. -- highlight the next one.
| otherwise -> replaceCompletion prevCompl | otherwise = replaceCompletion prevCompl
where where
hlCompl :: String = fromMaybe (command st) $ highlightedItem st l hlCompl :: String = fromMaybe (command st) $ highlightedItem st l
complIndex' :: (Int, Int) = nextComplIndex st (length l) complIndex' :: (Int, Int) = nextComplIndex st (length l)