From 4ce6882fc015bd06a337d6541fa847af92703b81 Mon Sep 17 00:00:00 2001 From: mafiesto4 Date: Tue, 9 Feb 2021 21:01:05 +0100 Subject: [PATCH] Add support for using VS Code as IDE for scripts on Linux --- .../CodeEditors/VisualStudioCodeEditor.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Source/Editor/Scripting/CodeEditors/VisualStudioCodeEditor.cpp b/Source/Editor/Scripting/CodeEditors/VisualStudioCodeEditor.cpp index 280f7fced..8c993ad25 100644 --- a/Source/Editor/Scripting/CodeEditors/VisualStudioCodeEditor.cpp +++ b/Source/Editor/Scripting/CodeEditors/VisualStudioCodeEditor.cpp @@ -42,6 +42,30 @@ void VisualStudioCodeEditor::FindEditors(Array* output) { output->Add(New(path, isInsiders)); } +#elif PLATFORM_LINUX + char buffer[128]; + FILE* pipe = popen("/bin/bash -c \"type -p code\"", "r"); + if (pipe) + { + StringAnsi pathAnsi; + while (fgets(buffer, sizeof(buffer), pipe) != NULL) + pathAnsi += buffer; + pclose(pipe); + const String path(pathAnsi.Get(), pathAnsi.Length() != 0 ? pathAnsi.Length() - 1 : 0); + if (FileSystem::FileExists(path)) + { + output->Add(New(path, false)); + return; + } + } + { + const String path(TEXT("/usr/bin/code")); + if (FileSystem::FileExists(path)) + { + output->Add(New(path, false)); + return; + } + } #endif }