From 6414cd259e7f271e0e7141866cbc79da7f589c93 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 2 Feb 2024 19:58:35 -0800 Subject: [PATCH 1/3] Reduce visual clutter in the debugger --- src/libcmd/repl.cc | 15 +++++++++++++-- src/libexpr/eval.cc | 4 +--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index d7d8f9819..5b4d3f9d5 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -243,10 +243,21 @@ static std::ostream & showDebugTrace(std::ostream & out, const PosTable & positi return out; } +static bool isFirstRepl = true; + void NixRepl::mainLoop() { - std::string error = ANSI_RED "error:" ANSI_NORMAL " "; - notice("Welcome to Nix " + nixVersion + ". Type :? for help.\n"); + if (isFirstRepl) { + std::string_view debuggerNotice = ""; + if (state->debugRepl) { + debuggerNotice = " debugger"; + } + notice("Nix %1%%2%\nType :? for help.", nixVersion, debuggerNotice); + } + + if (isFirstRepl) { + isFirstRepl = false; + } loadFiles(); diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 91fd3ddf8..dc2579dfa 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -821,12 +821,10 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr & if (error) { - printError("%s\n\n", error->what()); + printError("%s\n", error->what()); if (trylevel > 0 && error->info().level != lvlInfo) printError("This exception occurred in a 'tryEval' call. Use " ANSI_GREEN "--ignore-try" ANSI_NORMAL " to skip these.\n"); - - printError(ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL); } auto se = getStaticEnv(expr); From 155bc761f601346c8113cc760aaf26306136403c Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Mon, 5 Feb 2024 13:16:39 -0800 Subject: [PATCH 2/3] Add release note --- doc/manual/rl-next/reduce-debugger-clutter.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 doc/manual/rl-next/reduce-debugger-clutter.md diff --git a/doc/manual/rl-next/reduce-debugger-clutter.md b/doc/manual/rl-next/reduce-debugger-clutter.md new file mode 100644 index 000000000..9bc902eee --- /dev/null +++ b/doc/manual/rl-next/reduce-debugger-clutter.md @@ -0,0 +1,37 @@ +--- +synopsis: "Visual clutter in `--debugger` is reduced" +prs: 9919 +--- + +Before: +``` +info: breakpoint reached + + +Starting REPL to allow you to inspect the current state of the evaluator. + +Welcome to Nix 2.20.0pre20231222_dirty. Type :? for help. + +nix-repl> :continue +error: uh oh + + +Starting REPL to allow you to inspect the current state of the evaluator. + +Welcome to Nix 2.20.0pre20231222_dirty. Type :? for help. + +nix-repl> +``` + +After: + +``` +info: breakpoint reached + +Nix 2.20.0pre20231222_dirty debugger +Type :? for help. +nix-repl> :continue +error: uh oh + +nix-repl> +``` From d24c8aa49141fc384deafee50da65a05553a124b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= <7226587+thufschmitt@users.noreply.github.com> Date: Thu, 8 Feb 2024 09:22:30 +0100 Subject: [PATCH 3/3] Simplify a conditional in the repl initialisation --- src/libcmd/repl.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 5b4d3f9d5..9826f0fac 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -255,9 +255,7 @@ void NixRepl::mainLoop() notice("Nix %1%%2%\nType :? for help.", nixVersion, debuggerNotice); } - if (isFirstRepl) { - isFirstRepl = false; - } + isFirstRepl = false; loadFiles();