|
|
@ -4803,16 +4803,25 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
|
|
|
|
let mut ranges = SmallVec::with_capacity(selection.len());
|
|
|
|
let mut ranges = SmallVec::with_capacity(selection.len());
|
|
|
|
let text = doc.text().slice(..);
|
|
|
|
let text = doc.text().slice(..);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut shell_output: Option<Tendril> = None;
|
|
|
|
let mut offset = 0isize;
|
|
|
|
let mut offset = 0isize;
|
|
|
|
|
|
|
|
|
|
|
|
for range in selection.ranges() {
|
|
|
|
for range in selection.ranges() {
|
|
|
|
|
|
|
|
let (output, success) = if let Some(output) = shell_output.as_ref() {
|
|
|
|
|
|
|
|
(output.clone(), true)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
let fragment = range.slice(text);
|
|
|
|
let fragment = range.slice(text);
|
|
|
|
let (output, success) = match shell_impl(shell, cmd, pipe.then(|| fragment.into())) {
|
|
|
|
match shell_impl(shell, cmd, pipe.then(|| fragment.into())) {
|
|
|
|
Ok(result) => result,
|
|
|
|
Ok(result) => {
|
|
|
|
|
|
|
|
if !pipe {
|
|
|
|
|
|
|
|
shell_output = Some(result.0.clone());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result
|
|
|
|
|
|
|
|
}
|
|
|
|
Err(err) => {
|
|
|
|
Err(err) => {
|
|
|
|
cx.editor.set_error(err.to_string());
|
|
|
|
cx.editor.set_error(err.to_string());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if !success {
|
|
|
|
if !success {
|
|
|
|