From 4ae3dbd744de1f034706e0987e25fbd02dbcf4a8 Mon Sep 17 00:00:00 2001 From: Martin Verzilli Date: Mon, 16 Oct 2023 15:43:27 +0200 Subject: [PATCH 1/2] feat(debugger): highlight current src code loc --- Cargo.lock | 1 + tooling/debugger/Cargo.toml | 3 ++- tooling/debugger/src/lib.rs | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fadf637e31..d7787ac806e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2545,6 +2545,7 @@ dependencies = [ "easy-repl", "nargo", "noirc_printable_type", + "owo-colors", "thiserror", ] diff --git a/tooling/debugger/Cargo.toml b/tooling/debugger/Cargo.toml index 5b8248345a0..e01abd9ac61 100644 --- a/tooling/debugger/Cargo.toml +++ b/tooling/debugger/Cargo.toml @@ -13,4 +13,5 @@ acvm.workspace = true nargo.workspace = true noirc_printable_type.workspace = true thiserror.workspace = true -easy-repl = "0.2.1" \ No newline at end of file +easy-repl = "0.2.1" +owo-colors = "3" \ No newline at end of file diff --git a/tooling/debugger/src/lib.rs b/tooling/debugger/src/lib.rs index d1b0b350be3..d21eb8f6135 100644 --- a/tooling/debugger/src/lib.rs +++ b/tooling/debugger/src/lib.rs @@ -12,6 +12,8 @@ use nargo::ops::ForeignCallExecutor; use easy_repl::{command, CommandStatus, Critical, Repl}; use std::cell::{Cell, RefCell}; +use owo_colors::OwoColorize; + enum SolveResult { Done, Ok, @@ -85,7 +87,12 @@ impl<'backend, B: BlackBoxFunctionSolver> DebugContext<'backend, B> { let start = loc.span.start() as usize; let end = loc.span.end() as usize; println!("At {}.nr:{start}-{end}", file.path.as_path().display()); - println!("\n{}\n", &source[start..end]); + println!( + "\n{}{}{}\n", + &source[0..start], + &source[start..end].to_string().reversed(), + &source[end..] + ); } } } From 01432ddc907e7d27c19bfde664fea08bc8a43367 Mon Sep 17 00:00:00 2001 From: Martin Verzilli Date: Mon, 16 Oct 2023 17:32:25 +0200 Subject: [PATCH 2/2] Use dimme instead of reverse --- tooling/debugger/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tooling/debugger/src/lib.rs b/tooling/debugger/src/lib.rs index d21eb8f6135..82ef7ca3126 100644 --- a/tooling/debugger/src/lib.rs +++ b/tooling/debugger/src/lib.rs @@ -89,9 +89,9 @@ impl<'backend, B: BlackBoxFunctionSolver> DebugContext<'backend, B> { println!("At {}.nr:{start}-{end}", file.path.as_path().display()); println!( "\n{}{}{}\n", - &source[0..start], - &source[start..end].to_string().reversed(), - &source[end..] + &source[0..start].to_string().dimmed(), + &source[start..end], + &source[end..].to_string().dimmed(), ); } }