Skip to content

Commit 9f2bd57

Browse files
committed
Add Codium support to C# external editors
Selecting the VS Code option will now work if Codium is installed, picking it as the last option after attempting to run VS Code.
1 parent c6c464c commit 9f2bd57

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public void ShowConfirmCreateSlnDialog()
177177

178178
private static readonly string[] VsCodeNames =
179179
{
180-
"code", "code-oss", "vscode", "vscode-oss", "visual-studio-code", "visual-studio-code-oss"
180+
"code", "code-oss", "vscode", "vscode-oss", "visual-studio-code", "visual-studio-code-oss", "codium"
181181
};
182182

183183
[UsedImplicitly]
@@ -330,7 +330,7 @@ public Error OpenInExternalEditor(Script script, int line, int col)
330330
args.Add("-b");
331331
args.Add(vscodeBundleId);
332332

333-
// The reusing of existing windows made by the 'open' command might not choose a wubdiw that is
333+
// The reusing of existing windows made by the 'open' command might not choose a window that is
334334
// editing our folder. It's better to ask for a new window and let VSCode do the window management.
335335
args.Add("-n");
336336

@@ -339,6 +339,28 @@ public Error OpenInExternalEditor(Script script, int line, int col)
339339

340340
args.Add("--args");
341341
}
342+
343+
// Try VSCodium as a fallback if Visual Studio Code can't be found.
344+
if (!macOSAppBundleInstalled)
345+
{
346+
const string VscodiumBundleId = "com.vscodium.codium";
347+
macOSAppBundleInstalled = Internal.IsMacOSAppBundleInstalled(VscodiumBundleId);
348+
349+
if (macOSAppBundleInstalled)
350+
{
351+
args.Add("-b");
352+
args.Add(VscodiumBundleId);
353+
354+
// The reusing of existing windows made by the 'open' command might not choose a window that is
355+
// editing our folder. It's better to ask for a new window and let VSCode do the window management.
356+
args.Add("-n");
357+
358+
// The open process must wait until the application finishes (which is instant in VSCode's case)
359+
args.Add("--wait-apps");
360+
361+
args.Add("--args");
362+
}
363+
}
342364
}
343365

344366
args.Add(Path.GetDirectoryName(GodotSharpDirs.ProjectSlnPath)!);
@@ -361,7 +383,7 @@ public Error OpenInExternalEditor(Script script, int line, int col)
361383
{
362384
if (!macOSAppBundleInstalled && string.IsNullOrEmpty(_vsCodePath))
363385
{
364-
GD.PushError("Cannot find code editor: VSCode");
386+
GD.PushError("Cannot find code editor: Visual Studio Code or VSCodium");
365387
return Error.FileNotFound;
366388
}
367389

@@ -371,7 +393,7 @@ public Error OpenInExternalEditor(Script script, int line, int col)
371393
{
372394
if (string.IsNullOrEmpty(_vsCodePath))
373395
{
374-
GD.PushError("Cannot find code editor: VSCode");
396+
GD.PushError("Cannot find code editor: Visual Studio Code or VSCodium");
375397
return Error.FileNotFound;
376398
}
377399

@@ -384,7 +406,7 @@ public Error OpenInExternalEditor(Script script, int line, int col)
384406
}
385407
catch (Exception e)
386408
{
387-
GD.PushError($"Error when trying to run code editor: VSCode. Exception message: '{e.Message}'");
409+
GD.PushError($"Error when trying to run code editor: Visual Studio Code or VSCodium. Exception message: '{e.Message}'");
388410
}
389411

390412
break;
@@ -550,22 +572,22 @@ public override void _EnablePlugin()
550572
{
551573
settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudio}" +
552574
$",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
553-
$",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
575+
$",Visual Studio Code and VSCodium:{(int)ExternalEditorId.VsCode}" +
554576
$",JetBrains Rider and Fleet:{(int)ExternalEditorId.Rider}" +
555577
$",Custom:{(int)ExternalEditorId.CustomEditor}";
556578
}
557579
else if (OS.IsMacOS)
558580
{
559581
settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" +
560582
$",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
561-
$",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
583+
$",Visual Studio Code and VSCodium:{(int)ExternalEditorId.VsCode}" +
562584
$",JetBrains Rider and Fleet:{(int)ExternalEditorId.Rider}" +
563585
$",Custom:{(int)ExternalEditorId.CustomEditor}";
564586
}
565587
else if (OS.IsUnixLike)
566588
{
567589
settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
568-
$",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
590+
$",Visual Studio Code and VSCodium:{(int)ExternalEditorId.VsCode}" +
569591
$",JetBrains Rider and Fleet:{(int)ExternalEditorId.Rider}" +
570592
$",Custom:{(int)ExternalEditorId.CustomEditor}";
571593
}

0 commit comments

Comments
 (0)