Mono: Fix regression: external editors not working on Windows
This commit is contained in:
parent
513cc78f85
commit
c0cdbb7938
3 changed files with 26 additions and 12 deletions
|
@ -298,7 +298,16 @@ namespace GodotTools
|
||||||
if (line >= 0)
|
if (line >= 0)
|
||||||
scriptPath += $";{line + 1};{col}";
|
scriptPath += $";{line + 1};{col}";
|
||||||
|
|
||||||
GetMonoDevelopInstance(GodotSharpDirs.ProjectSlnPath).Execute(scriptPath);
|
try
|
||||||
|
{
|
||||||
|
GetMonoDevelopInstance(GodotSharpDirs.ProjectSlnPath).Execute(scriptPath);
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
string editorName = editor == ExternalEditor.VisualStudioForMac ? "Visual Studio" : "MonoDevelop";
|
||||||
|
GD.PushError($"Cannot find code editor: {editorName}");
|
||||||
|
return Error.FileNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using GodotTools.Internals;
|
using GodotTools.Internals;
|
||||||
|
using GodotTools.Utils;
|
||||||
|
|
||||||
namespace GodotTools
|
namespace GodotTools
|
||||||
{
|
{
|
||||||
|
@ -30,7 +31,7 @@ namespace GodotTools
|
||||||
|
|
||||||
if (Utils.OS.IsOSX())
|
if (Utils.OS.IsOSX())
|
||||||
{
|
{
|
||||||
string bundleId = CodeEditorBundleIds[editorId];
|
string bundleId = BundleIds[editorId];
|
||||||
|
|
||||||
if (Internal.IsOsxAppBundleInstalled(bundleId))
|
if (Internal.IsOsxAppBundleInstalled(bundleId))
|
||||||
{
|
{
|
||||||
|
@ -47,12 +48,12 @@ namespace GodotTools
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
command = CodeEditorPaths[editorId];
|
command = OS.PathWhich(ExecutableNames[editorId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
command = CodeEditorPaths[editorId];
|
command = OS.PathWhich(ExecutableNames[editorId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
args.Add("--ipc-tcp");
|
args.Add("--ipc-tcp");
|
||||||
|
@ -70,6 +71,9 @@ namespace GodotTools
|
||||||
args.Add("\"" + Path.GetFullPath(filePath.NormalizePath()) + cursor + "\"");
|
args.Add("\"" + Path.GetFullPath(filePath.NormalizePath()) + cursor + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command == null)
|
||||||
|
throw new FileNotFoundException();
|
||||||
|
|
||||||
if (newWindow)
|
if (newWindow)
|
||||||
{
|
{
|
||||||
process = Process.Start(new ProcessStartInfo
|
process = Process.Start(new ProcessStartInfo
|
||||||
|
@ -99,20 +103,20 @@ namespace GodotTools
|
||||||
this.editorId = editorId;
|
this.editorId = editorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly IReadOnlyDictionary<EditorId, string> CodeEditorPaths;
|
private static readonly IReadOnlyDictionary<EditorId, string> ExecutableNames;
|
||||||
private static readonly IReadOnlyDictionary<EditorId, string> CodeEditorBundleIds;
|
private static readonly IReadOnlyDictionary<EditorId, string> BundleIds;
|
||||||
|
|
||||||
static MonoDevelopInstance()
|
static MonoDevelopInstance()
|
||||||
{
|
{
|
||||||
if (Utils.OS.IsOSX())
|
if (Utils.OS.IsOSX())
|
||||||
{
|
{
|
||||||
CodeEditorPaths = new Dictionary<EditorId, string>
|
ExecutableNames = new Dictionary<EditorId, string>
|
||||||
{
|
{
|
||||||
// Rely on PATH
|
// Rely on PATH
|
||||||
{EditorId.MonoDevelop, "monodevelop"},
|
{EditorId.MonoDevelop, "monodevelop"},
|
||||||
{EditorId.VisualStudioForMac, "VisualStudio"}
|
{EditorId.VisualStudioForMac, "VisualStudio"}
|
||||||
};
|
};
|
||||||
CodeEditorBundleIds = new Dictionary<EditorId, string>
|
BundleIds = new Dictionary<EditorId, string>
|
||||||
{
|
{
|
||||||
// TODO EditorId.MonoDevelop
|
// TODO EditorId.MonoDevelop
|
||||||
{EditorId.VisualStudioForMac, "com.microsoft.visual-studio"}
|
{EditorId.VisualStudioForMac, "com.microsoft.visual-studio"}
|
||||||
|
@ -120,7 +124,7 @@ namespace GodotTools
|
||||||
}
|
}
|
||||||
else if (Utils.OS.IsWindows())
|
else if (Utils.OS.IsWindows())
|
||||||
{
|
{
|
||||||
CodeEditorPaths = new Dictionary<EditorId, string>
|
ExecutableNames = new Dictionary<EditorId, string>
|
||||||
{
|
{
|
||||||
// XamarinStudio is no longer a thing, and the latest version is quite old
|
// XamarinStudio is no longer a thing, and the latest version is quite old
|
||||||
// MonoDevelop is available from source only on Windows. The recommendation
|
// MonoDevelop is available from source only on Windows. The recommendation
|
||||||
|
@ -131,7 +135,7 @@ namespace GodotTools
|
||||||
}
|
}
|
||||||
else if (Utils.OS.IsUnix())
|
else if (Utils.OS.IsUnix())
|
||||||
{
|
{
|
||||||
CodeEditorPaths = new Dictionary<EditorId, string>
|
ExecutableNames = new Dictionary<EditorId, string>
|
||||||
{
|
{
|
||||||
// Rely on PATH
|
// Rely on PATH
|
||||||
{EditorId.MonoDevelop, "monodevelop"}
|
{EditorId.MonoDevelop, "monodevelop"}
|
||||||
|
|
|
@ -10,8 +10,9 @@ namespace GodotTools.Utils
|
||||||
{
|
{
|
||||||
foreach (T elem in enumerable)
|
foreach (T elem in enumerable)
|
||||||
{
|
{
|
||||||
if (predicate(elem) != null)
|
T result = predicate(elem);
|
||||||
return elem;
|
if (result != null)
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return orElse;
|
return orElse;
|
||||||
|
|
Loading…
Reference in a new issue