diff options
author | Andrea Rossato <andrea.rossato@unibz.it> | 2007-08-15 18:34:57 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@unibz.it> | 2007-08-15 18:34:57 +0200 |
commit | 3be471b1ae883c6b5326c9bdb66ad6d77fea5280 (patch) | |
tree | 21e9da1e304ceb4608228a06bf67626ffc21ced8 | |
parent | efaf5377c971423db4ad6ee8644fbeeb97a678bf (diff) | |
download | XMonadContrib-3be471b1ae883c6b5326c9bdb66ad6d77fea5280.tar.gz XMonadContrib-3be471b1ae883c6b5326c9bdb66ad6d77fea5280.tar.xz XMonadContrib-3be471b1ae883c6b5326c9bdb66ad6d77fea5280.zip |
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
-rw-r--r-- | XPrompt.hs | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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 [] = [] |