about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-08-29T16·13+0200
committerGitHub <noreply@github.com>2018-08-29T16·13+0200
commit1286d86b9540841a9fa451c8e7ee0a6d48ae2527 (patch)
tree26d428422d46fe6e2dd9047ea66fde4de035907c
parentd16ff76c69318c4ef04b1dcc873a72910b8eca49 (diff)
parentec49ea28dc5309c8905fc4385fb65ec7a88b33f6 (diff)
Merge pull request #2336 from ivan/repl-trailing-spaces
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 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;
     }