diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs index 62db6e3af5f..51c7a8aa226 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs @@ -385,9 +385,12 @@ namespace GodotTools.Ides // However, it doesn't fix resource loading if the rest of the path is also case insensitive. string scriptFileLocalized = FsPathUtils.LocalizePathWithCaseChecked(request.ScriptFile); + // The node API can only be called from the main thread. + await Godot.Engine.GetMainLoop().ToSignal(Godot.Engine.GetMainLoop(), "process_frame"); + var response = new CodeCompletionResponse { Kind = request.Kind, ScriptFile = request.ScriptFile }; - response.Suggestions = await Task.Run(() => - Internal.CodeCompletionRequest(response.Kind, scriptFileLocalized ?? request.ScriptFile)); + response.Suggestions = Internal.CodeCompletionRequest(response.Kind, + scriptFileLocalized ?? request.ScriptFile); return response; } }