|
|
@ -2,20 +2,20 @@ use crate::Editor;
|
|
|
|
use std::borrow::Cow;
|
|
|
|
use std::borrow::Cow;
|
|
|
|
|
|
|
|
|
|
|
|
impl Editor {
|
|
|
|
impl Editor {
|
|
|
|
pub fn expand_variables<'a>(
|
|
|
|
pub fn expand_variables_in_vec<'a>(
|
|
|
|
&self,
|
|
|
|
&self,
|
|
|
|
args: &'a Vec<Cow<'a, str>>,
|
|
|
|
args: &'a Vec<Cow<'a, str>>,
|
|
|
|
) -> anyhow::Result<Vec<Cow<'a, str>>> {
|
|
|
|
) -> anyhow::Result<Vec<Cow<'a, str>>> {
|
|
|
|
let mut output = Vec::with_capacity(args.len());
|
|
|
|
let mut output = Vec::with_capacity(args.len());
|
|
|
|
for arg in args {
|
|
|
|
for arg in args {
|
|
|
|
if let Ok(s) = self.expand_arg(arg) {
|
|
|
|
if let Ok(s) = self.expand_variable_in_string(arg) {
|
|
|
|
output.push(s);
|
|
|
|
output.push(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Ok(output)
|
|
|
|
Ok(output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn expand_arg<'a>(&self, input: &'a str) -> anyhow::Result<Cow<'a, str>> {
|
|
|
|
pub fn expand_variable_in_string<'a>(&self, input: &'a str) -> anyhow::Result<Cow<'a, str>> {
|
|
|
|
let (view, doc) = current_ref!(self);
|
|
|
|
let (view, doc) = current_ref!(self);
|
|
|
|
let shell = &self.config().shell;
|
|
|
|
let shell = &self.config().shell;
|
|
|
|
|
|
|
|
|
|
|
@ -94,7 +94,9 @@ impl Editor {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(o) = output.as_mut() {
|
|
|
|
if let Some(o) = output.as_mut() {
|
|
|
|
let body = self.expand_arg(&input[index + 4..end])?;
|
|
|
|
let body = self.expand_variable_in_string(
|
|
|
|
|
|
|
|
&input[index + 4..end],
|
|
|
|
|
|
|
|
)?;
|
|
|
|
|
|
|
|
|
|
|
|
let output = tokio::task::block_in_place(move || {
|
|
|
|
let output = tokio::task::block_in_place(move || {
|
|
|
|
helix_lsp::block_on(async move {
|
|
|
|
helix_lsp::block_on(async move {
|
|
|
|