Skip to content

Commit

Permalink
Implemented {project} placeholder for external dotnet editor
Browse files Browse the repository at this point in the history
Implements the {project} placeholder, available when setting an external editor
in the project settings, via Editor > Editor Settings > Text Editor > External
for the c# external editor, under Editor > Editor Settings > Dotnet > Editor,

This allows passing the project folder as a command line argument when using a
custom external editor that isn't one of the available options.

Fixes #81845
  • Loading branch information
crazyStewie committed Sep 20, 2023
1 parent 4df80b0 commit c01a478
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ public Error OpenInExternalEditor(Script script, int line, int col)
case ExternalEditorId.CustomEditor:
{
string file = ProjectSettings.GlobalizePath(script.ResourcePath);
string project = ProjectSettings.GlobalizePath("res://");
// Since ProjectSettings.GlobalizePath replaces only "res:/", leaving a trailing slash, it is removed here.
project = project[..^1];
var execCommand = _editorSettings.GetSetting(Settings.CustomExecPath).As<string>();
var execArgs = _editorSettings.GetSetting(Settings.CustomExecPathArgs).As<string>();
var args = new List<string>();
Expand Down Expand Up @@ -226,6 +229,7 @@ public Error OpenInExternalEditor(Script script, int line, int col)
hasFileFlag = true;
}

arg = arg.ReplaceN("{project}", project);
arg = arg.ReplaceN("{file}", file);
args.Add(arg);

Expand Down

0 comments on commit c01a478

Please sign in to comment.