Commit cd307a05 authored by lykahb@gmail.com's avatar lykahb@gmail.com
Browse files

Remove context completion

Now completion suggests to remove only modules added to context before.
parent f10947d7
......@@ -140,7 +140,7 @@ builtin_commands = [
("kind", keepGoing' kindOfType, completeIdentifier),
("load", keepGoingPaths loadModule_, completeHomeModuleOrFile),
("list", keepGoing' listCmd, noCompletion),
("module", keepGoing setContext, completeModule),
("module", keepGoing setContext, completeSetModule),
("main", keepGoing runMain, completeFilename),
("print", keepGoing printCmd, completeExpression),
("quit", quit, noCompletion),
......@@ -1711,6 +1711,18 @@ completeModule = wrapIdentCompleter $ \w -> do
return $ filter (w `isPrefixOf`)
$ map (showSDoc.ppr) $ loaded_mods ++ pkg_mods
completeSetModule = wrapIdentCompleterWithModifier "+-" $ \m w -> do
modules <- case m of
Just '-' -> do
(toplevs, exports) <- GHC.getContext
return $ map GHC.moduleName (nub (map fst exports) ++ toplevs)
otherwise -> do
dflags <- GHC.getSessionDynFlags
let pkg_mods = allExposedModules dflags
loaded_mods <- liftM (map GHC.ms_mod_name) getLoadedModules
return $ loaded_mods ++ pkg_mods
return $ filter (w `isPrefixOf`) $ map (showSDoc.ppr) modules
completeHomeModule = wrapIdentCompleter listHomeModules
listHomeModules :: String -> GHCi [String]
......@@ -1748,6 +1760,12 @@ wrapCompleter breakChars fun = completeWord Nothing breakChars
wrapIdentCompleter :: (String -> GHCi [String]) -> CompletionFunc GHCi
wrapIdentCompleter = wrapCompleter word_break_chars
wrapIdentCompleterWithModifier :: String -> (Maybe Char -> String -> GHCi [String]) -> CompletionFunc GHCi
wrapIdentCompleterWithModifier modifChars fun = completeWordWithPrev Nothing word_break_chars
$ \rest -> fmap (map simpleCompletion) . fmap sort . fun (getModifier rest)
where
getModifier = find (`elem` modifChars)
allExposedModules :: DynFlags -> [ModuleName]
allExposedModules dflags
= concat (map exposedModules (filter exposed (eltsUFM pkg_db)))
......
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