@@ -214,10 +214,14 @@ data CompletionContext = Command String | FilePath String | Module | Identifier
214214-- Decide what kind of completion we need based on input.
215215completionContext :: String -> String -> Maybe CompletionContext
216216completionContext cmd@"" _ = Just $ Multiple [Command cmd, Identifier]
217−completionContext cmd@(":") _ = Just $ Command cmd
218−completionContext (':' : cmd) word = do
219− context =<< D.parseDirective (takeWhile (not . isSpace) cmd)
217+completionContext (':' : cmd) word =
218+ case D.parseDirective dstr of
219+ Just directive | dstr `elem` D.commands directive -> context directive
220+ _ -> Just $ Command cmd
220221 where
222+ dstr :: String
223+ dstr = takeWhile (not . isSpace) cmd
224+
221225 context :: D.Directive -> Maybe CompletionContext
222226 context D.Import = Just Module
223227 context D.Browse = Just Module
@@ -254,7 +258,7 @@ completion = completeWordWithPrev Nothing " \t\n\r" findCompletions
254258 getCompletion Type = (map Left) <$> getTypeNames
255259 getCompletion (Fixed list) = return $ (map Left) list
256260 getCompletion (Multiple contexts) = concat <$> mapM getCompletion contexts
257− getCompletion (Command cmd) = return . map Left . nub $ matching
261+ getCompletion (Command cmd) = return . map (Left . (":" ++)) . nub $ matching
258262 where
259263 matching :: [String]
260264 matching = filter (isPrefixOf cmd) . concatMap (D.commands) $ D.directives