From 9ceedcd19d0a47bb8934b09b559d4f89602b509f Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Tue, 25 Feb 2025 16:10:00 -0800 Subject: [PATCH] Make `testImplicitCancellationOnEdit` more robust Instead of adding an arbitrary `Task.sleep` that should give us enough time to send the `textDocument/didChange` notification, wait until we receive the cancellation from the document change. --- Tests/SourceKitLSPTests/SemanticTokensTests.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/SourceKitLSPTests/SemanticTokensTests.swift b/Tests/SourceKitLSPTests/SemanticTokensTests.swift index 4e722888c..2814c8045 100644 --- a/Tests/SourceKitLSPTests/SemanticTokensTests.swift +++ b/Tests/SourceKitLSPTests/SemanticTokensTests.swift @@ -897,8 +897,9 @@ final class SemanticTokensTests: XCTestCase { let testClient = try await TestSourceKitLSPClient( hooks: Hooks(preHandleRequest: { request in if request is DocumentSemanticTokensRequest { - // Sleep long enough for the edit to be handled - try? await Task.sleep(for: .seconds(10)) + while !Task.isCancelled { + try? await Task.sleep(for: .seconds(1)) + } } }) )