From f4be01b4be4a509bec6d79cef0810da34b0e5128 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Fri, 5 Dec 2025 01:47:03 +0100 Subject: [PATCH] libcmd/repl: do not clear the environment on empty reloads If `:reload` is used with no file loaded, the environment is completely cleared. That's a surprising behavior and one of the root cause behind #50. Environment clear is only performed if there's files to reload. Change-Id: Icb014f490a83aaa4d758dbf37822db16d5bb65c1 Signed-off-by: Raito Bezarius --- lix/libcmd/repl.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lix/libcmd/repl.cc b/lix/libcmd/repl.cc index cdfc88be5..4b871733f 100644 --- a/lix/libcmd/repl.cc +++ b/lix/libcmd/repl.cc @@ -1354,6 +1354,11 @@ void NixRepl::initEnv() void NixRepl::reloadFiles() { + if (loaded.empty() && getValues().empty()) { + notice("No file to reload, skipping"); + return; + } + initEnv(); loadFiles();