aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/command.cc
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2022-01-08 15:43:04 -0700
committerBen Burdette <bburdette@gmail.com>2022-01-08 15:43:04 -0700
commit990bec78d30c5e23cd6aa83a6f98b1d4199bd8c3 (patch)
treeeaa0706ccbf825773856123b175f3dcfc55faf31 /src/libcmd/command.cc
parenta963674d88f2f1af6181f126ed4288ec65b61fc6 (diff)
clear screen and show top debug trace
Diffstat (limited to 'src/libcmd/command.cc')
-rw-r--r--src/libcmd/command.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc
index ed8f6d295..5848a15bf 100644
--- a/src/libcmd/command.cc
+++ b/src/libcmd/command.cc
@@ -77,8 +77,30 @@ ref<EvalState> EvalCommand::getEvalState()
searchPath, getEvalStore(), getStore());
if (startReplOnEvalErrors)
debuggerHook = [evalState{ref<EvalState>(evalState)}](const Error * error, const Env & env, const Expr & expr) {
+ std::cout << "\033[2J\033[1;1H";
+
if (error)
printError("%s\n\n" ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL, error->what());
+ else
+ {
+ auto iter = evalState->debugTraces.begin();
+ if (iter != evalState->debugTraces.end()) {
+ std::cout << "\n" << "… " << iter->hint.str() << "\n";
+
+ if (iter->pos.has_value() && (*iter->pos)) {
+ auto pos = iter->pos.value();
+ std::cout << "\n";
+ printAtPos(pos, std::cout);
+
+ auto loc = getCodeLines(pos);
+ if (loc.has_value()) {
+ std::cout << "\n";
+ printCodeLines(std::cout, "", pos, *loc);
+ std::cout << "\n";
+ }
+ }
+ }
+ }
if (expr.staticenv)
{