From 23436e7980ca058db0160aa234e1057efad3e12d Mon Sep 17 00:00:00 2001 From: Martin Verzilli Date: Mon, 9 Oct 2023 17:56:05 +0200 Subject: [PATCH] feat: highlight loc in debugger --- Cargo.lock | 12 ++++++++++++ tooling/debugger/Cargo.toml | 3 ++- tooling/debugger/src/lib.rs | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cfbef76dc9..ca8d9b97e66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -883,6 +883,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "colored" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" +dependencies = [ + "is-terminal", + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -2498,6 +2509,7 @@ name = "noir_debugger" version = "0.16.0" dependencies = [ "acvm", + "colored", "easy-repl", "nargo", "noirc_printable_type", diff --git a/tooling/debugger/Cargo.toml b/tooling/debugger/Cargo.toml index 5b8248345a0..20f043e772d 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" +colored = "2.0.4" \ No newline at end of file diff --git a/tooling/debugger/src/lib.rs b/tooling/debugger/src/lib.rs index 306b8c7f301..63b9d590e22 100644 --- a/tooling/debugger/src/lib.rs +++ b/tooling/debugger/src/lib.rs @@ -14,6 +14,8 @@ use thiserror::Error; use easy_repl::{command, CommandStatus, Critical, Repl}; use std::cell::{Cell, RefCell}; +use colored::Colorize; + enum SolveResult { Done, Ok, @@ -109,7 +111,7 @@ impl<'backend, B: BlackBoxFunctionSolver> DebugContext<'backend, B> { let start = loc.span.start() as usize; let end = loc.span.end() as usize; println!("At {}:{start}-{end}", file.path.as_path().display()); - println!("\n{}\n", &source[start..end]); + println!("\n{}{}{}\n", &source[0..start], &source[start..end].reversed(), &source[end..]); } } None => {}