From 12967aea53e2f546636f1517dddcd30a22abe303 Mon Sep 17 00:00:00 2001 From: Sarah Brofeldt Date: Sun, 28 Apr 2024 16:32:58 +0200 Subject: [PATCH 1/2] nix repl: hide progress bar during :edit (cherry picked from commit e5f509ef0b5c364544c904faa0bfda57dba03611) --- src/libcmd/repl.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index a045e83d2..bade1b538 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -506,6 +506,10 @@ ProcessLineResult NixRepl::processLine(std::string line) auto editor = args.front(); args.pop_front(); + // avoid garbling the editor with the progress bar + logger->pause(); + Finally resume([&]() { logger->resume(); }); + // runProgram redirects stdout to a StringSink, // using runProgram2 to allow editors to display their UI runProgram2(RunOptions { .program = editor, .lookupPath = true, .args = args }); From f00aa37873559b0412ebfdbd3334e7e67502b8cb Mon Sep 17 00:00:00 2001 From: eihqnh Date: Mon, 13 May 2024 21:12:58 +0800 Subject: [PATCH 2/2] nix repl: make runNix() isInteractive is true by default (cherry picked from commit bb1a4ea21a6af3c37c7d1c948e36678c96c3f499) --- src/libcmd/repl.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index bade1b538..c3a099d52 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -137,12 +137,13 @@ void runNix(Path program, const Strings & args, { auto subprocessEnv = getEnv(); subprocessEnv["NIX_CONFIG"] = globalConfig.toKeyValue(); - + //isInteractive avoid grabling interactive commands runProgram2(RunOptions { .program = settings.nixBinDir+ "/" + program, .args = args, .environment = subprocessEnv, .input = input, + .isInteractive = true, }); return; @@ -506,13 +507,9 @@ ProcessLineResult NixRepl::processLine(std::string line) auto editor = args.front(); args.pop_front(); - // avoid garbling the editor with the progress bar - logger->pause(); - Finally resume([&]() { logger->resume(); }); - // runProgram redirects stdout to a StringSink, // using runProgram2 to allow editors to display their UI - runProgram2(RunOptions { .program = editor, .lookupPath = true, .args = args }); + runProgram2(RunOptions { .program = editor, .lookupPath = true, .args = args , .isInteractive = true }); // Reload right after exiting the editor state->resetFileCache();