Merge pull request #220 from j4qfrost/macos-app-crash

Fix MacOS crash launching from Finder
macos-click-through
Keith Simmons 5 years ago committed by GitHub
commit 07ba8574f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,26 +34,46 @@ fn set_windows_creation_flags(cmd: &mut Command) {
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
fn build_cmd() -> Command { fn platform_build_nvim_cmd(bin: &str) -> Command {
if std::env::args() if std::env::args()
.collect::<Vec<String>>() .collect::<Vec<String>>()
.contains(&String::from("--wsl")) .contains(&String::from("--wsl"))
{ {
let mut cmd = Command::new("wsl"); let mut cmd = Command::new("wsl");
cmd.arg("nvim"); cmd.arg(bin);
cmd cmd
} else { } else {
Command::new("nvim") Command::new(bin)
} }
} }
#[cfg(not(target_os = "windows"))] #[cfg(target_os = "macos")]
fn build_cmd() -> Command { fn platform_build_nvim_cmd(bin: &str) -> Command {
Command::new("nvim") use std::path::Path;
let default_path = "/usr/local/bin/nvim";
if Path::new(&bin).exists() {
Command::new(bin)
} else {
Command::new(default_path)
}
}
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
fn platform_build_nvim_cmd(bin: &str) -> Command {
Command::new(bin)
}
fn build_nvim_cmd() -> Command {
let key = "NEOVIM_BIN";
match std::env::var_os(key) {
Some(path) => platform_build_nvim_cmd(&path.to_string_lossy()),
None => platform_build_nvim_cmd("nvim"),
}
} }
fn create_nvim_command() -> Command { fn create_nvim_command() -> Command {
let mut cmd = build_cmd(); let mut cmd = build_nvim_cmd();
cmd.arg("--embed") cmd.arg("--embed")
.args(SETTINGS.neovim_arguments.iter().skip(1)) .args(SETTINGS.neovim_arguments.iter().skip(1))

Loading…
Cancel
Save