From 6bef982f2d259cdecb8e249cf1ec4d5e20bb8b38 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Wed, 30 Aug 2023 07:51:03 -0700 Subject: [PATCH] use which on formatter command (#8064) --- helix-view/src/document.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 19f37c711..36dbbcb8b 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -733,16 +733,16 @@ pub fn auto_format(&self) -> Option Option>> { - if let Some(formatter) = self + if let Some((fmt_cmd, fmt_args)) = self .language_config() - .and_then(|c| c.formatter.clone()) - .filter(|formatter| which::which(&formatter.command).is_ok()) + .and_then(|c| c.formatter.as_ref()) + .and_then(|formatter| Some((which::which(&formatter.command).ok()?, &formatter.args))) { use std::process::Stdio; let text = self.text().clone(); - let mut process = tokio::process::Command::new(&formatter.command); + let mut process = tokio::process::Command::new(&fmt_cmd); process - .args(&formatter.args) + .args(fmt_args) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()); @@ -751,7 +751,7 @@ pub fn format(&self) -> Option