From 3be471b1ae883c6b5326c9bdb66ad6d77fea5280 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Wed, 15 Aug 2007 18:34:57 +0200 Subject: 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. darcs-hash:20070815163457-32816-13dc80cfb1fccaca6717df60072f2d3e9fc68bf7.gz --- XPrompt.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'XPrompt.hs') diff --git a/XPrompt.hs b/XPrompt.hs index 165697f..c6b1c78 100644 --- a/XPrompt.hs +++ b/XPrompt.hs @@ -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 [] = [] -- cgit v1.2.3