@@ -102,8 +102,7 @@ struct NixRepl
102102 unsigned int maxDepth = std::numeric_limits<unsigned int >::max())
103103 {
104104 // Hide the progress bar during printing because it might interfere
105- logger->pause ();
106- Finally resumeLoggerDefer ([]() { logger->resume (); });
105+ auto suspension = logger->suspend ();
107106 ::nix::printValue (*state, str, v, PrintOptions {
108107 .ansiColors = true ,
109108 .force = true ,
@@ -180,18 +179,20 @@ ReplExitStatus NixRepl::mainLoop()
180179
181180 while (true ) {
182181 // Hide the progress bar while waiting for user input, so that it won't interfere.
183- logger->pause ();
184- // When continuing input from previous lines, don't print a prompt, just align to the same
185- // number of chars as the prompt.
186- if (!interacter->getLine (input, input.empty () ? ReplPromptType::ReplPrompt : ReplPromptType::ContinuationPrompt)) {
187- // Ctrl-D should exit the debugger.
188- state->debugStop = false ;
189- logger->cout (" " );
190- // TODO: Should Ctrl-D exit just the current debugger session or
191- // the entire program?
192- return ReplExitStatus::QuitAll;
182+ {
183+ auto suspension = logger->suspend ();
184+ // When continuing input from previous lines, don't print a prompt, just align to the same
185+ // number of chars as the prompt.
186+ if (!interacter->getLine (input, input.empty () ? ReplPromptType::ReplPrompt : ReplPromptType::ContinuationPrompt)) {
187+ // Ctrl-D should exit the debugger.
188+ state->debugStop = false ;
189+ logger->cout (" " );
190+ // TODO: Should Ctrl-D exit just the current debugger session or
191+ // the entire program?
192+ return ReplExitStatus::QuitAll;
193+ }
194+ // `suspension` resumes the logger
193195 }
194- logger->resume ();
195196 try {
196197 switch (processLine (input)) {
197198 case ProcessLineResult::Quit:
@@ -586,6 +587,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
586587 else if (command == " :p" || command == " :print" ) {
587588 Value v;
588589 evalString (arg, v);
590+ auto suspension = logger->suspend ();
589591 if (v.type () == nString) {
590592 std::cout << v.string_view ();
591593 } else {
@@ -694,6 +696,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
694696 } else {
695697 Value v;
696698 evalString (line, v);
699+ auto suspension = logger->suspend ();
697700 printValue (std::cout, v, 1 );
698701 std::cout << std::endl;
699702 }
0 commit comments