From 43cedec6c535971d6c1cc86b009187ff742d505f Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Mon, 4 Mar 2024 08:52:57 +0100 Subject: [PATCH] Merge pull request #9919 from 9999years/reduce-debugger-clutter Reduce visual clutter in the debugger (cherry picked from commit f388a6148dae0fc999f1a67d0b96d76788f9b97f) Change-Id: I21bfe3e9f75816484b0f46dbe09e0ff40b22c6d9 --- doc/manual/rl-next/reduce-debugger-clutter.md | 37 +++++++++++++++++++ src/libcmd/repl.cc | 13 ++++++- src/libexpr/eval.cc | 4 +- 3 files changed, 49 insertions(+), 5 deletions(-) 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> +``` diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index f5abaad9b..bcd887d76 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -232,10 +232,19 @@ 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); + } + + isFirstRepl = false; loadFiles(); diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 309b9f103..a1782dcad 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -887,12 +887,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);