Skip to content

Commit

Permalink
repl: don't add trailing spaces to history lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan committed Aug 7, 2018
1 parent 103ad15 commit ec49ea2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/nix/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ec49ea2

Please sign in to comment.