From 32a307ed262fde8ab53bea3bf27bd87c8f4edf89 Mon Sep 17 00:00:00 2001 From: Snezhkko Date: Thu, 13 Nov 2025 19:31:21 +0200 Subject: [PATCH] fix(chisel): guard inspect() behind do_execute to avoid redundant compile/execute --- crates/chisel/src/dispatcher.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 6b611e795f3ce..442ced813a17a 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -132,15 +132,16 @@ impl ChiselDispatcher { // Create new source with exact input appended and parse let (new_source, do_execute) = source.clone_with_new_line(input.to_string())?; - // TODO: Cloning / parsing the session source twice on non-inspected inputs kinda sucks. - // Should change up how this works. - let (cf, res) = source.inspect(input).await?; - if let Some(res) = &res { - let _ = sh_println!("{res}"); - } - if cf.is_break() { - debug!(%input, ?res, "inspect success"); - return Ok(ControlFlow::Continue(())); + // Only inspect when the snippet is appended to run() and will be executed. + if do_execute { + let (cf, res) = source.inspect(input).await?; + if let Some(res) = &res { + let _ = sh_println!("{res}"); + } + if cf.is_break() { + debug!(%input, ?res, "inspect success"); + return Ok(ControlFlow::Continue(())); + } } if do_execute {