autocompletion update
This commit is contained in:
14
ml.cpp
14
ml.cpp
@@ -2135,7 +2135,7 @@ bool MlEnvironment::has(const std::string &name) const {
|
||||
|
||||
|
||||
|
||||
std::map <const std::string, Builtin> builtin_funcs
|
||||
std::map<const std::string, Builtin> builtin_funcs
|
||||
{
|
||||
// Special forms
|
||||
std::make_pair("def", builtin::define),
|
||||
@@ -2287,14 +2287,12 @@ MlValue MlEnvironment::get(const std::string &name) const {
|
||||
}
|
||||
|
||||
// Get vector of executables in this scope
|
||||
std::vector<std::string> MlEnvironment::get_lambdas_list() const {
|
||||
std::vector<std::string> lambdas{128};
|
||||
std::vector<std::string> MlEnvironment::get_lambdas_list(const std::string &token) const {
|
||||
std::vector<std::string> lambdas{};
|
||||
|
||||
for (auto it = defs.begin(); it != defs.end(); it++) {
|
||||
if (it->second.get_type_name() == FUNCTION_TYPE) {
|
||||
for (auto it = defs.begin(); it != defs.end(); it++)
|
||||
if (it->second.get_type_name() == FUNCTION_TYPE && (token.empty() || it->first.find(token) == 0))
|
||||
lambdas.push_back(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
return lambdas;
|
||||
}
|
||||
@@ -2306,7 +2304,7 @@ void repl(MlEnvironment &env) {
|
||||
MlValue tmp;
|
||||
std::vector<MlValue> parsed;
|
||||
|
||||
setup_linenoise(env);
|
||||
setup_linenoise(env, builtin_funcs);
|
||||
|
||||
while (true) {
|
||||
char *line = linenoise(">>> ");
|
||||
|
||||
Reference in New Issue
Block a user