repl: don't add trailing spaces to history lines

This commit is contained in:
Ivan Kozik 2018-08-07 03:40:44 +00:00
parent 103ad1598c
commit ec49ea28dc

View file

@ -173,9 +173,14 @@ void NixRepl::mainLoop(const std::vector<std::string> & files)
printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg()); printMsg(lvlError, format(error + "%1%%2%") % (settings.showTrace ? e.prefix() : "") % e.msg());
} }
if (input.size() > 0) {
// Remove trailing newline before adding to history
input.erase(input.size() - 1);
linenoiseHistoryAdd(input.c_str());
}
// We handled the current input fully, so we should clear it // We handled the current input fully, so we should clear it
// and read brand new input. // and read brand new input.
linenoiseHistoryAdd(input.c_str());
input.clear(); input.clear();
std::cout << std::endl; std::cout << std::endl;
} }