Commit 521fcf58 authored by David Himmelstrup's avatar David Himmelstrup
Browse files

Bugfix in completion code for :set and :unset.

parent a5b7c95f
...@@ -1195,7 +1195,7 @@ completeWord w start end = do ...@@ -1195,7 +1195,7 @@ completeWord w start end = do
_other _other
| Just c <- is_cmd line -> do | Just c <- is_cmd line -> do
maybe_cmd <- lookupCommand c maybe_cmd <- lookupCommand c
let (n,w') = selectWord 0 (words line) let (n,w') = selectWord (words' 0 line)
case maybe_cmd of case maybe_cmd of
Nothing -> return Nothing Nothing -> return Nothing
Just (_,_,False,complete) -> wrapCompleter complete w Just (_,_,False,complete) -> wrapCompleter complete w
...@@ -1205,10 +1205,17 @@ completeWord w start end = do ...@@ -1205,10 +1205,17 @@ completeWord w start end = do
| otherwise -> do | otherwise -> do
--printf "complete %s, start = %d, end = %d\n" w start end --printf "complete %s, start = %d, end = %d\n" w start end
wrapCompleter completeIdentifier w wrapCompleter completeIdentifier w
where selectWord _ [] = (0,w) where words' _ [] = []
selectWord n (x:xs) words' n str = let (w,r) = break isSpace str
| n+length x >= start = (start-n-1,take (end-n+1) x) (s,r') = span isSpace r
| otherwise = selectWord (n+length x) xs 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 is_cmd line
| ((':':w) : _) <- words (dropWhile isSpace line) = Just w | ((':':w) : _) <- words (dropWhile isSpace line) = Just w
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment