Skip to content

Commit

Permalink
fix: Not parsing sh body
Browse files Browse the repository at this point in the history
  • Loading branch information
ksdrar committed Apr 25, 2023
1 parent 8bf040f commit 07b109d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
fn expand_args(editor: &Editor, args: &str) -> anyhow::Result<String> {
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(&regexp, args, move |captures| {
let keyword = captures.get(1).unwrap().as_str();
Expand Down Expand Up @@ -2901,7 +2902,7 @@ fn expand_args(editor: &mut Editor, args: &str) -> anyhow::Result<String> {
_ => 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())
}
Expand Down

0 comments on commit 07b109d

Please sign in to comment.