Skip to content

Commit

Permalink
fix: #968 (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellerve authored Feb 1, 2021
1 parent e42922e commit ce69cec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 10 additions & 0 deletions src/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ envBindingNames = concatMap select . envBindings
select (Binder _ (XObj (Mod m) _ _)) = envBindingNames m
select (Binder _ obj) = [getName obj]

envPublicBindingNames :: Env -> [String]
envPublicBindingNames = concatMap select . envBindings
where
select :: Binder -> [String]
select (Binder _ (XObj (Mod m) _ _)) = envPublicBindingNames m
select (Binder meta obj) =
if metaIsTrue meta "private" || metaIsTrue meta "hidden"
then []
else [getName obj]

-- | Recursively look through all environments for (def ...) forms.
findAllGlobalVariables :: Env -> [Binder]
findAllGlobalVariables env =
Expand Down
12 changes: 2 additions & 10 deletions src/Repl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,15 @@ import System.Exit (exitSuccess)

completeKeywordsAnd :: Context -> String -> [Completion]
completeKeywordsAnd context word =
findKeywords word (envBindingNames (contextGlobalEnv context) ++ keywords) []
findKeywords word (envPublicBindingNames (contextGlobalEnv context) ++ keywords) []
where
findKeywords _ [] res = res
findKeywords match (x : xs) res =
if match `isPrefixOf` x
then findKeywords match xs (res ++ [simpleCompletion x])
else findKeywords match xs res
keywords =
[ "Int", -- we should probably have a list of those somewhere
"Float",
"Double",
"Bool",
"String",
"Char",
"Array",
"Fn",
"def",
[ "def",
"defn",
"let",
"do",
Expand Down

0 comments on commit ce69cec

Please sign in to comment.