From f7a2cf2177b7a12db59216a4b904f2af1de7e3a0 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 16 Jul 2020 07:29:45 -0400 Subject: [PATCH] Fix editScript() on Mac. Disable "Edit script" menu item when editor is not set. --- src/Prototype.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Prototype.cpp b/src/Prototype.cpp index 6ed3955..8f3fe2a 100644 --- a/src/Prototype.cpp +++ b/src/Prototype.cpp @@ -468,11 +468,14 @@ struct Prototype : Module { if (path.empty()) return; // Launch editor and detach - std::string command = editorPath + " \"" + path + "\""; -#if defined ARCH_LIN || defined ARCH_MAC - command += " &"; +#if defined ARCH_LIN + std::string command = editorPath + " \"" + path + "\" &"; + std::system(command.c_str()); +#elif defined ARCH_MAC + std::string command = "open -a " + editorPath + " \"" + path + "\" &"; std::system(command.c_str()); #elif defined ARCH_WIN + std::string command = editorPath + " \"" + path + "\""; std::wstring commandW = string::toWstring(command); STARTUPINFOW startupInfo; std::memset(&startupInfo, 0, sizeof(startupInfo)); @@ -536,7 +539,7 @@ struct Prototype : Module { }; EditScriptItem* editScriptItem = createMenuItem("Edit script"); editScriptItem->module = this; - editScriptItem->disabled = !doesPathExist(); + editScriptItem->disabled = !doesPathExist() || editorPath == ""; menu->addChild(editScriptItem); struct SetEditorItem : MenuItem {