Skip to content

Commit

Permalink
Uses unwrap_or when setting formatting process directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Gonnella committed Dec 27, 2024
1 parent 75c8980 commit 1e83176
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,11 @@ impl Document {
use std::process::Stdio;
let text = self.text().clone();
let mut process = tokio::process::Command::new(&fmt_cmd);
if let Some(path) = self.path.clone() {
if let Some(parent) = path.parent() {
process.current_dir(parent);
}
}
let doc_path = self.path.clone().unwrap_or(PathBuf::from(file!()));
let doc_dir = doc_path.parent().unwrap_or(Path::new("."));

process
.current_dir(doc_dir)
.args(fmt_args)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
Expand Down

0 comments on commit 1e83176

Please sign in to comment.