some refactorings

This commit is contained in:
2022-01-02 12:45:53 +01:00
parent d3a373ce94
commit ebb69b6096
10 changed files with 57 additions and 54 deletions

View File

@@ -25,7 +25,6 @@ std::string get_history_file_dir() {
else return std::string{t} + "/" + file;
}
// TODO fujtajbl
MlEnvironment * repl_env = nullptr;
void setup_linenoise(const MlEnvironment &env) {
@@ -69,13 +68,13 @@ void completion(const char *buf, linenoiseCompletions *lc) {
std::string token = str.substr(pos+1);
std::string begining = str.substr(0, pos+1);
// TODO optimize not to get all lambdas, but those begining with token
// TODO optimize not to get all lambdas, but those beginning with token
std::vector<std::string> lambdas = repl_env->get_lambdas_list();
lambdas.insert(end(lambdas), begin(commands), end(commands));
for (std::vector<std::string>::iterator t = lambdas.begin(); t != lambdas.end(); ++t) {
if(t->find(token) == 0) {
std::string completion_string = begining + *t;
for (const auto & lambda : lambdas) {
if(lambda.find(token) == 0) {
std::string completion_string = begining + lambda;
linenoiseAddCompletion(lc, completion_string.c_str());
}
}