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 <raito@lix.systems>
This commit is contained in:
Raito Bezarius
2026-01-08 18:35:13 +01:00
committed by Qyriad
parent 0f1208c406
commit f4be01b4be
+5
View File
@@ -1354,6 +1354,11 @@ void NixRepl::initEnv()
void NixRepl::reloadFiles()
{
if (loaded.empty() && getValues().empty()) {
notice("No file to reload, skipping");
return;
}
initEnv();
loadFiles();