@@ -214,10 +214,14 @@ data CompletionContext = Command String | FilePath String | Module | Identifier
214-- Decide what kind of completion we need based on input.
214-- Decide what kind of completion we need based on input.
215completionContext :: String -> String -> Maybe CompletionContext
215completionContext :: String -> String -> Maybe CompletionContext
216completionContext cmd@"" _ = Just $ Multiple [Command cmd, Identifier]
216completionContext cmd@"" _ = Just $ Multiple [Command cmd, Identifier]
217−completionContext cmd@(":") _ = Just $ Command cmd
217+completionContext (':' : cmd) word =
218−completionContext (':' : cmd) word = do
219− context =<< D.parseDirective (takeWhile (not . isSpace) cmd)
218+ case D.parseDirective dstr of
219+ Just directive | dstr `elem` D.commands directive -> context directive
220+ _ -> Just $ Command cmd
223+ dstr = takeWhile (not . isSpace) cmd
221 context :: D.Directive -> Maybe CompletionContext
225 context :: D.Directive -> Maybe CompletionContext
222 context D.Import = Just Module
226 context D.Import = Just Module
223 context D.Browse = Just Module
227 context D.Browse = Just Module
@@ -254,7 +258,7 @@ completion = completeWordWithPrev Nothing " \t\n\r" findCompletions
254 getCompletion Type = (map Left) <$> getTypeNames
258 getCompletion Type = (map Left) <$> getTypeNames
255 getCompletion (Fixed list) = return $ (map Left) list
259 getCompletion (Fixed list) = return $ (map Left) list
256 getCompletion (Multiple contexts) = concat <$> mapM getCompletion contexts
260 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
259 matching :: [String]
263 matching :: [String]
260 matching = filter (isPrefixOf cmd) . concatMap (D.commands) $ D.directives
264 matching = filter (isPrefixOf cmd) . concatMap (D.commands) $ D.directives