X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=c5edfa6c40c97d1049b26d4e5a229717f72b5918;hp=839cee32a3c0cfae3069e2a21eb7b3d75bfe6f42;hb=521fcf58f8b10e2bd0299f823ef8919e63d0ed28;hpb=a5b7c95f084eacc9133de9265f0d8bdbf6043fa1 diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 839cee3..c5edfa6 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1195,7 +1195,7 @@ completeWord w start end = do _other | Just c <- is_cmd line -> do maybe_cmd <- lookupCommand c - let (n,w') = selectWord 0 (words line) + let (n,w') = selectWord (words' 0 line) case maybe_cmd of Nothing -> return Nothing Just (_,_,False,complete) -> wrapCompleter complete w @@ -1205,10 +1205,17 @@ completeWord w start end = do | otherwise -> do --printf "complete %s, start = %d, end = %d\n" w start end wrapCompleter completeIdentifier w - where selectWord _ [] = (0,w) - selectWord n (x:xs) - | n+length x >= start = (start-n-1,take (end-n+1) x) - | otherwise = selectWord (n+length x) xs + where words' _ [] = [] + words' n str = let (w,r) = break isSpace str + (s,r') = span isSpace r + in (n,w):words' (n+length w+length s) r' + -- In a Haskell expression we want to parse 'a-b' as three words + -- where a compiler flag (ie. -fno-monomorphism-restriction) should + -- only be a single word. + selectWord [] = (0,w) + selectWord ((offset,x):xs) + | offset+length x >= start = (start-offset,take (end-offset) x) + | otherwise = selectWord xs is_cmd line | ((':':w) : _) <- words (dropWhile isSpace line) = Just w