diff --git a/packages/cursorless-vscode-e2e/src/suite/performance.vscode.test.ts b/packages/cursorless-vscode-e2e/src/suite/performance.vscode.test.ts index d2c03de1cf..1ef5fa9b0c 100644 --- a/packages/cursorless-vscode-e2e/src/suite/performance.vscode.test.ts +++ b/packages/cursorless-vscode-e2e/src/suite/performance.vscode.test.ts @@ -90,11 +90,10 @@ suite("Performance", async function () { } test( - "Select surroundingPair with multiple cursors", + "Select collectionKey with multiple cursors", asyncSafety(() => selectWithMultipleCursors(largeThresholdMs, { - type: "surroundingPair", - delimiter: "any", + type: "collectionKey", }), ), ); @@ -107,6 +106,16 @@ suite("Performance", async function () { }), ), ); + + test( + "Select surroundingPair.any with multiple cursors", + asyncSafety(() => + selectWithMultipleCursors(largeThresholdMs, { + type: "surroundingPair", + delimiter: "any", + }), + ), + ); }); function removeToken(thresholdMs: number) { @@ -120,27 +129,29 @@ function removeToken(thresholdMs: number) { } function selectWithMultipleCursors(thresholdMs: number, scopeType: ScopeType) { - return testPerformanceCallback( - thresholdMs, - () => { - return runCursorlessAction({ - name: "setSelectionBefore", - target: { - type: "primitive", - modifiers: [getModifier({ type: "collectionItem" }, "every")], - }, - }); - }, - () => { - return runCursorlessAction({ - name: "setSelection", - target: { - type: "primitive", - modifiers: [getModifier(scopeType)], - }, - }); - }, - ); + const beforeCallback = async (editor: vscode.TextEditor) => { + await runCursorlessAction({ + name: "setSelectionBefore", + target: { + type: "primitive", + modifiers: [getModifier({ type: "collectionItem" }, "every")], + }, + }); + + assert.equal(editor.selections.length, 100, "Expected 100 cursors"); + }; + + const callback = () => { + return runCursorlessAction({ + name: "setSelection", + target: { + type: "primitive", + modifiers: [getModifier(scopeType)], + }, + }); + }; + + return testPerformanceCallback(thresholdMs, callback, beforeCallback); } function selectScopeType( @@ -166,7 +177,7 @@ function testPerformance(thresholdMs: number, action: ActionDescriptor) { async function testPerformanceCallback( thresholdMs: number, callback: () => Promise, - beforeCallback?: () => Promise, + beforeCallback?: (editor: vscode.TextEditor) => Promise, ) { const editor = await openNewEditor(testData, { languageId: "json" }); // This is the position of the last json key in the document @@ -176,7 +187,7 @@ async function testPerformanceCallback( editor.revealRange(selection); if (beforeCallback != null) { - await beforeCallback(); + await beforeCallback(editor); } const start = performance.now();