From 20a69abfd9e3592939f253cc95c2e38d8a9019ca Mon Sep 17 00:00:00 2001 From: pacexy <pacexy@gmail.com> Date: Wed, 29 Jan 2025 19:44:40 +0800 Subject: [PATCH] support editor arguments --- src/exercise.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/exercise.rs b/src/exercise.rs index e018c7f8..6d2cd783 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -83,7 +83,21 @@ impl Exercise { /// Open the exercise file in the specified editor pub fn open_in_editor(&self, editor: &str) -> io::Result<bool> { - let status = Command::new(editor).arg(self.path).status()?; + let parts: Vec<&str> = editor.split_whitespace().collect(); + if parts.is_empty() { + return Ok(false); + } + + let mut cmd = Command::new(parts[0]); + + // If the editor command has arguments, add them to the command + if parts.len() > 1 { + cmd.args(&parts[1..]); + } + + cmd.arg(self.path); + + let status = cmd.status()?; Ok(status.success()) } }