As I already noted in the comments, the reason for this behaviour is the GHCi doesn't properly reset the prompt when Ctrl-C
is pressed. The source of the problem probably lies in the following code (Taken from ghci-ng
):
multiLineCmd q = do
st <- lift getGHCiState
let p = prompt st
lift $ setGHCiState st{ prompt = prompt2 st }
mb_cmd <- collectCommand q ""
lift $ getGHCiState >>= \st' -> setGHCiState st'{ prompt = p }
return mb_cmd
(See InteractiveUI.hs line 712)
If collectCommand
throws UserInterrupt
, then the line that resets the promt will never be executed. I changed this code to:
multiLineCmd q = do
st <- lift getGHCiState
let p = prompt st
lift $ setGHCiState st{ prompt = prompt2 st }
mb_cmd <- collectCommand q "" `GHC.gfinally` lift (getGHCiState >>= \st' -> setGHCiState st'{ prompt = p })
return mb_cmd
Which fixes the problem.