diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 28341259c..4bb95ccc9 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -300,7 +300,7 @@ ReplExitStatus NixRepl::mainLoop() /* Stop the progress bar because it interferes with the display of the repl. */ - stopProgressBar(); + logger->pause(); std::string input; @@ -684,9 +684,22 @@ ProcessLineResult NixRepl::processLine(std::string line) // TODO: this only shows a progress bar for explicitly initiated builds, // not eval-time fetching or builds performed for IFD. // But we can't just show it everywhere, since that would erase partial output from evaluation. - startProgressBar(); + logger->resume(); Finally stopLogger([&]() { - stopProgressBar(); + logger->pause(); + if (auto * progressBar = dynamic_cast(logger)) { + auto state(progressBar->state_.lock()); + bool const prevActive = state->active; + bool const prevPaused = state->paused; + bool const prevHaveUpdate = state->haveUpdate; + // HACK: reset the state, except for those three booleans, so the + // stats of multiple builds in the same repl session don't mingle. + *state = ProgressBar::State{ + .active = prevActive, + .paused = prevPaused, + .haveUpdate = prevHaveUpdate, + }; + } }); state->store->buildPaths({