aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPuck Meerburg <puck@puckipedia.com>2024-05-19 14:16:11 +0000
committerPuck Meerburg <puck@puckipedia.com>2024-05-19 22:47:45 +0000
commitbfb91db4f6a580b4f90a511a79185db4aa3f34d3 (patch)
treebef0d5056ea6277c9ef86d70d401439e8999616e
parent40311973a835aceb866b7d4465c286c700a59ad4 (diff)
repl-interacter: save history after entering every line
Fixes: https://git.lix.systems/lix-project/lix/issues/328 Change-Id: Iedd79ff5f72e84766ebd234c63856170afc624f0
-rw-r--r--doc/manual/rl-next/repl-fix-history.md9
-rw-r--r--src/libcmd/repl-interacter.cc2
2 files changed, 11 insertions, 0 deletions
diff --git a/doc/manual/rl-next/repl-fix-history.md b/doc/manual/rl-next/repl-fix-history.md
new file mode 100644
index 000000000..1517f68e7
--- /dev/null
+++ b/doc/manual/rl-next/repl-fix-history.md
@@ -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.
diff --git a/src/libcmd/repl-interacter.cc b/src/libcmd/repl-interacter.cc
index 829383add..d3567e021 100644
--- a/src/libcmd/repl-interacter.cc
+++ b/src/libcmd/repl-interacter.cc
@@ -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;