XPrompt: fixes a nasty bug in getLastWord

This patch fixes a nasty bug in getLastWord, a bug that causes XMonad
to crash as soon as the command line consists of only 2 empty spaces.
*PLEASE UPDATE* if you are running XPrompt.
This commit is contained in:
Andrea Rossato 2007-08-15 16:34:57 +00:00
parent 039a76c9cb
commit 990d65eb3e

View File

@ -166,9 +166,11 @@ eventLoop action = do
d <- gets dpy
(keysym,string,event) <- io $
allocaXEvent $ \e -> do
maskEvent d keyPressMask e
maskEvent d (exposureMask .|. keyPressMask) e
ev <- getEvent e
(ks,s) <- lookupString $ asKeyEvent e
(ks,s) <- if ev_event_type ev == keyPress
then lookupString $ asKeyEvent e
else return (Nothing, "")
return (ks,s,ev)
action (fromMaybe xK_VoidSymbol keysym,string) event
@ -616,8 +618,9 @@ splitInSubListsAt i x = f : splitInSubListsAt i rest
where (f,rest) = splitAt i x
getLastWord :: String -> String
getLastWord [] = []
getLastWord c = last . words $ c
getLastWord c
| c == [] || filter (/=' ') c == [] = []
| otherwise = last . words $ c
skipLastWord :: String -> String
skipLastWord [] = []