Skip to content

Commit

Permalink
feat(debugger): highlight current src code loc (noir-lang#3174)
Browse files Browse the repository at this point in the history
  • Loading branch information
mverzilli authored and Sakapoi committed Oct 19, 2023
1 parent 9dccaf8 commit 9166af8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tooling/debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ acvm.workspace = true
nargo.workspace = true
noirc_printable_type.workspace = true
thiserror.workspace = true
easy-repl = "0.2.1"
easy-repl = "0.2.1"
owo-colors = "3"
9 changes: 8 additions & 1 deletion tooling/debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {}:{start}-{end}", file.path.as_path().display());
println!("\n{}\n", &source[start..end]);
println!(
"\n{}{}{}\n",
&source[0..start].to_string().dimmed(),
&source[start..end],
&source[end..].to_string().dimmed(),
);
}
}
}
Expand Down

0 comments on commit 9166af8

Please sign in to comment.