diff --git a/packages/lsp-core/src/lsp/fixtures/workspace-edit-server.mjs b/packages/lsp-core/src/lsp/fixtures/workspace-edit-server.mjs index 53376ad2bd6..298afc23f2d 100644 --- a/packages/lsp-core/src/lsp/fixtures/workspace-edit-server.mjs +++ b/packages/lsp-core/src/lsp/fixtures/workspace-edit-server.mjs @@ -182,6 +182,9 @@ function handleNotification(message) { } if (message.method === "textDocument/didOpen") { applyPublishSteps("didOpen", message.params.textDocument.uri, message.params.textDocument.version); + if (scenario.unscopedApplyEditOnDidOpen) { + sendApplyEdit(scenario.unscopedApplyEditOnDidOpen, { kind: "unscoped" }); + } } if (message.method === "textDocument/didChange" && Array.isArray(scenario.diagnostics)) { send({ diff --git a/packages/lsp-core/src/lsp/workspace-apply-edit-lease.integration.test.ts b/packages/lsp-core/src/lsp/workspace-apply-edit-lease.integration.test.ts index f30db66396d..78c92f6cb6a 100644 --- a/packages/lsp-core/src/lsp/workspace-apply-edit-lease.integration.test.ts +++ b/packages/lsp-core/src/lsp/workspace-apply-edit-lease.integration.test.ts @@ -7,6 +7,7 @@ import { readEvents, renameTextEdit, waitForEventCount, + waitForEventCountBySubscription, } from "./workspace-apply-edit-test-support.js"; const harness = createWorkspaceEditTestHarness(); @@ -17,13 +18,16 @@ afterEach(async () => { describe("LspClient workspace mutation lease", () => { it("#given no mutating request #when the server calls applyEdit #then the request is rejected as unscoped", async () => { - const context = await harness.makeClient({ unscopedApplyEdit: renameTextEdit("before", "after", { version: 1 }) }); - - const responses = await waitForEventCount( + const context = await harness.makeClient({ + unscopedApplyEditOnDidOpen: renameTextEdit("before", "after", { version: 1 }), + }); + const response = waitForEventCountBySubscription( context.events, (event) => event.type === "clientResponse" && event.method === "workspace/applyEdit", 1, ); + await context.client.openFile(context.source); + const responses = await response; expect(responses[0]?.result).toEqual({ applied: false,