Add vscode detection on macOS

This commit is contained in:
Wojtek Figat
2023-02-28 18:49:32 +01:00
parent f88dd50098
commit 82a22b2a87
2 changed files with 56 additions and 2 deletions

View File

@@ -10,6 +10,9 @@
#include "Engine/Platform/Win32/IncludeWindowsHeaders.h"
#if PLATFORM_LINUX
#include <stdio.h>
#elif PLATFORM_MAC
#include "Engine/Platform/Mac/MacUtils.h"
#include <AppKit/AppKit.h>
#endif
VisualStudioCodeEditor::VisualStudioCodeEditor(const String& execPath, const bool isInsiders)
@@ -80,6 +83,33 @@ void VisualStudioCodeEditor::FindEditors(Array<CodeEditor*>* output)
return;
}
}
#elif PLATFORM_MAC
// System installed app
NSURL* AppURL = [[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:@"com.microsoft.VSCode"];
if (AppURL != nullptr)
{
const String path = MacUtils::ToString((CFStringRef)[AppURL path]);
output->Add(New<VisualStudioCodeEditor>(path, false));
return;
}
// Predefined locations
String userFolder;
FileSystem::GetSpecialFolderPath(SpecialFolder::Documents, userFolder);
String paths[3] =
{
TEXT("/Applications/Visual Studio Code.app"),
userFolder + TEXT("/../Visual Studio Code.app"),
userFolder + TEXT("/../Downloads/Visual Studio Code.app"),
};
for (const String& path : paths)
{
if (FileSystem::DirectoryExists(path))
{
output->Add(New<VisualStudioCodeEditor>(path, false));
break;
}
}
#endif
}