From 07b109d289e429d4058480f3087301d07f3001a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20R?= Date: Mon, 24 Apr 2023 19:14:58 -0600 Subject: [PATCH] fix: Not parsing sh body --- helix-term/src/commands/typed.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 981a97ad827f..4bf1b925ff22 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2866,11 +2866,12 @@ pub(super) fn command_mode(cx: &mut Context) { cx.push_layer(Box::new(prompt)); } -fn expand_args(editor: &mut Editor, args: &str) -> anyhow::Result { +fn expand_args(editor: &Editor, args: &str) -> anyhow::Result { let regexp = regex::Regex::new(r"%(\w+)\s*\{([^{}]*(\{[^{}]*\}[^{}]*)*)\}").unwrap(); + let view = editor.tree.get(editor.tree.focus); + let doc = editor.documents.get(&view.doc).unwrap(); let shell = &editor.config().shell; - let (view, doc) = current!(editor); replace_all(®exp, args, move |captures| { let keyword = captures.get(1).unwrap().as_str(); @@ -2901,7 +2902,7 @@ fn expand_args(editor: &mut Editor, args: &str) -> anyhow::Result { _ => anyhow::bail!("Unknown variable: {body}"), }, "sh" => { - let result = shell_impl(shell, body, None)?; + let result = shell_impl(shell, &expand_args(editor, body)?, None)?; Ok(result.0.trim().to_string()) }