about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorIvan Kozik <ivan@ludios.org>2018-08-07T03·40+0000
committerIvan Kozik <ivan@ludios.org>2018-08-07T03·59+0000
commitec49ea28dc5309c8905fc4385fb65ec7a88b33f6 (patch)
tree0356ea79ff269c03ada4142257277e81428a93d5 /src
parent103ad1598c4708735412ffbb4f8ef9730ec071d2 (diff)
repl: don't add trailing spaces to history lines
Diffstat (limited to 'src')
-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 1eb716006375..b71e6f905f23 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;
     }