Merge pull request #2336 from ivan/repl-trailing-spaces

repl: don't add trailing spaces to history lines
This commit is contained in:
Eelco Dolstra 2018-08-29 18:13:29 +02:00 committed by GitHub
commit 1286d86b95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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());
}
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
// and read brand new input.
linenoiseHistoryAdd(input.c_str());
input.clear();
std::cout << std::endl;
}