-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
It is unable to open the editor of choice as set in the EDITOR env var in Windows on Powershell while it runs fine in bash, attached is a reproducible error
possible workaround:
use std::env;
use std::path::PathBuf;
use std::process::Command;
fn open_in_editor(file_path: PathBuf) {
if let Some(editor) = env::var("EDITOR").ok() {
// Check if running on Windows
if cfg!(target_os = "windows") {
// Use PowerShell on Windows
Command::new("powershell")
.arg("-Command")
.arg(format!(r#"{} "{}""#, editor, file_path.display()))
.spawn()
.unwrap()
.wait()
.unwrap();
} else {
// Use "sh" for Unix-like systems
Command::new("sh")
.arg("-c")
.arg(format!(r#"{} "{}""#, editor, file_path.display()))
.spawn()
.unwrap()
.wait()
.unwrap();
}
} else {
eprintln!("Error: EDITOR environment variable not set.");
}
}Metadata
Metadata
Assignees
Labels
No labels
