repl-interacter: save history after entering every line

Fixes: lix-project/lix#328
Change-Id: Iedd79ff5f72e84766ebd234c63856170afc624f0
This commit is contained in:
puck 2024-05-19 14:16:11 +00:00
parent 40311973a8
commit bfb91db4f6
2 changed files with 11 additions and 0 deletions

View file

@ -0,0 +1,9 @@
---
synopsis: "`nix repl` history is saved more reliably"
cls: 1164
credits: puck
---
`nix repl` now saves its history file after each line, rather than at the end
of the session; ensuring that it will remember what you typed even after it
crashes.

View file

@ -175,6 +175,8 @@ bool ReadlineLikeInteracter::getLine(std::string & input, ReplPromptType promptT
if (!s)
return false;
write_history(historyFile.c_str());
input += s;
input += '\n';
return true;