From 64b186d6ff945748eda277a7b2dd1c6298df8fd1 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Wed, 22 Oct 2025 21:21:38 +1000 Subject: [PATCH] ensure tab ordering --- .../Features/CodeEditor/SharpIdeCodeEdit.cs | 15 +++++++++------ src/SharpIDE.Godot/IdeRoot.cs | 5 ++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs b/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs index 9d74052..e240ce9 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs @@ -353,12 +353,15 @@ public partial class SharpIdeCodeEdit : CodeEdit _fileChangingSuppressBreakpointToggleEvent = false; if (fileLinePosition is not null) SetFileLinePosition(fileLinePosition.Value); }); - await Task.WhenAll(syntaxHighlighting, razorSyntaxHighlighting, setTextTask); // Text must be set before setting syntax highlighting - await this.InvokeAsync(async () => SetSyntaxHighlightingModel(await syntaxHighlighting, await razorSyntaxHighlighting)); - await diagnostics; - await this.InvokeAsync(async () => SetDiagnostics(await diagnostics)); - await projectDiagnosticsForFile; - await this.InvokeAsync(async () => SetProjectDiagnostics(await projectDiagnosticsForFile)); + _ = Task.GodotRun(async () => + { + await Task.WhenAll(syntaxHighlighting, razorSyntaxHighlighting, setTextTask); // Text must be set before setting syntax highlighting + await this.InvokeAsync(async () => SetSyntaxHighlightingModel(await syntaxHighlighting, await razorSyntaxHighlighting)); + await diagnostics; + await this.InvokeAsync(async () => SetDiagnostics(await diagnostics)); + await projectDiagnosticsForFile; + await this.InvokeAsync(async () => SetProjectDiagnostics(await projectDiagnosticsForFile)); + }); } public void UnderlineRange(int line, int caretStartCol, int caretEndCol, Color color, float thickness = 1.5f) diff --git a/src/SharpIDE.Godot/IdeRoot.cs b/src/SharpIDE.Godot/IdeRoot.cs index 26c9dc7..b5aaa5e 100644 --- a/src/SharpIDE.Godot/IdeRoot.cs +++ b/src/SharpIDE.Godot/IdeRoot.cs @@ -160,12 +160,11 @@ public partial class IdeRoot : Control // Preserves order of tabs foreach (var (file, linePosition, isSelected) in filesToOpen) { - GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, linePosition); - await Task.Delay(10).ConfigureAwait(false); // TODO: Do this properly - use InvokeParallelAsync, and fix FileExternallySelected waiting on syntax highlighting etc before returning + await GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelAsync(file, linePosition); } // Select the selected tab var selectedFile = filesToOpen.SingleOrDefault(f => f.IsSelected); - if (selectedFile.Item1 is not null) GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(selectedFile.Item1, selectedFile.Item2); + if (selectedFile.Item1 is not null) await GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelAsync(selectedFile.Item1, selectedFile.Item2); }); var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList();