diff --git a/Editor.Tests/Extensions/CommandServiceExtensions.cs b/Editor.Tests/Extensions/CommandServiceExtensions.cs index ef55e83..a181f54 100644 --- a/Editor.Tests/Extensions/CommandServiceExtensions.cs +++ b/Editor.Tests/Extensions/CommandServiceExtensions.cs @@ -70,8 +70,22 @@ public static void CheckAndExecute ( LogTrace ("Session open"); RegisterTraceHandlers (session); } + // If we have a session, but it hasn't started yet, wait for it to start. + // We previously called session.GetComputedItems to wait for the completion + // to be updated, but on slow machines, e.g. on CI, this could cause completion + // to be dismissed (TryDismissSafelyAsync) before it was even shown. + if (session is IAsyncCompletionSessionOperations sessionOperations) { + // wait up to 2.5 seconds in 25ms intervals + for (int i = 0; i < 100; i++) { + if (sessionOperations.IsStarted) { + break; + } + Thread.Sleep (25); + } + } + //ensure the computation is completed before we continue typing - session.GetComputedItems (CancellationToken.None); + //session.GetComputedItems (CancellationToken.None); LogTrace ("Session open"); } } else{