diff --git a/Cargo.lock b/Cargo.lock index 3b7bff9..0ba35bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1367,6 +1367,7 @@ dependencies = [ "rmpv", "serde", "serde_json", + "shlex", "skia-safe", "swash", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 6a52df7..ffb315f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ rand = "0.8.5" rmpv = "1.0.0" serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.79" +shlex = "1.1.0" swash = "0.1.4" tokio = { version = "1.17.0", features = ["full"] } tokio-util = { version = "0.7.1", features = ["compat"] } diff --git a/src/cmd_line.rs b/src/cmd_line.rs index 6b94c39..4882b32 100644 --- a/src/cmd_line.rs +++ b/src/cmd_line.rs @@ -172,11 +172,10 @@ pub fn handle_command_line_arguments(args: Vec) -> Result<(), String> { if cfg!(target_os = "macos") { // escape filepath which contain spaces - neovim_args.extend::>( + neovim_args.extend( files_to_open .iter() - .map(|file| file.replace(" ", "\\ ")) - .collect(), + .map(|file| shlex::quote(file).into_owned()), ); } else { neovim_args.extend::>(files_to_open);