on master help sign in
use which on formatter command (#8064)
commit6bef982f2d259cdecb8e249cf1ec4d5e20bb8b38 authorEzekiel Warren <zaucy@users.noreply.github.com> dateWed 30 Aug 2023, 07:51 (3 years ago) parent7fffc0a
1 file changed+6−6
helix-view/src/document.rs+6−6
helix-view/src/document.rs+6−6
@@ -733,16 +733,16 @@ impl Document {
733733 // We can't use anyhow::Result here since the output of the future has to be
734734 // clonable to be used as shared future. So use a custom error type.
735735 pub fn format(&self) -> Option<BoxFuture<'static, Result<Transaction, FormatterError>>> {
736− if let Some(formatter) = self
736+ if let Some((fmt_cmd, fmt_args)) = self
737737 .language_config()
738− .and_then(|c| c.formatter.clone())
739− .filter(|formatter| which::which(&formatter.command).is_ok())
738+ .and_then(|c| c.formatter.as_ref())
739+ .and_then(|formatter| Some((which::which(&formatter.command).ok()?, &formatter.args)))
740740 {
741741 use std::process::Stdio;
742742 let text = self.text().clone();
743− let mut process = tokio::process::Command::new(&formatter.command);
743+ let mut process = tokio::process::Command::new(&fmt_cmd);
744744 process
745− .args(&formatter.args)
745+ .args(fmt_args)
746746 .stdin(Stdio::piped())
747747 .stdout(Stdio::piped())
748748 .stderr(Stdio::piped());
@@ -751,7 +751,7 @@ impl Document {
751751 let mut process = process
752752 .spawn()
753753 .map_err(|e| FormatterError::SpawningFailed {
754− command: formatter.command.clone(),
754+ command: fmt_cmd.to_string_lossy().into(),
755755 error: e.kind(),
756756 })?;
757757 {