From a83c23bb037a2db26f3e2fe519de22425e95a7d8 Mon Sep 17 00:00:00 2001 From: Rob Gonnella Date: Wed, 8 Jan 2025 13:36:40 -0500 Subject: [PATCH] Run formatter from Document directory (#12315) Co-authored-by: Rob Gonnella --- helix-view/src/document.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 29fd736a..edbc96b0 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -774,7 +774,13 @@ impl Document { { use std::process::Stdio; let text = self.text().clone(); + let mut process = tokio::process::Command::new(&fmt_cmd); + + if let Some(doc_dir) = self.path.as_ref().and_then(|path| path.parent()) { + process.current_dir(doc_dir); + } + process .args(fmt_args) .stdin(Stdio::piped())