aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kozik <ivan@ludios.org>2018-08-07 03:40:44 +0000
committerIvan Kozik <ivan@ludios.org>2018-08-07 03:59:34 +0000
commitec49ea28dc5309c8905fc4385fb65ec7a88b33f6 (patch)
tree0356ea79ff269c03ada4142257277e81428a93d5
parent103ad1598c4708735412ffbb4f8ef9730ec071d2 (diff)
repl: don't add trailing spaces to history lines
-rw-r--r--src/nix/repl.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 1eb716006..b71e6f905 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -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;
}