From 4eb3c544d0fd716ff4956eb4f531ae9c6f34a6e9 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 3 Jan 2026 12:47:45 +0100 Subject: [PATCH 1/2] Fix bug with multiple cursor performance tests --- .../src/suite/performance.vscode.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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..acf4c6b31f 100644 --- a/packages/cursorless-vscode-e2e/src/suite/performance.vscode.test.ts +++ b/packages/cursorless-vscode-e2e/src/suite/performance.vscode.test.ts @@ -124,19 +124,19 @@ function selectWithMultipleCursors(thresholdMs: number, scopeType: ScopeType) { thresholdMs, () => { return runCursorlessAction({ - name: "setSelectionBefore", + name: "setSelection", target: { type: "primitive", - modifiers: [getModifier({ type: "collectionItem" }, "every")], + modifiers: [getModifier(scopeType)], }, }); }, () => { return runCursorlessAction({ - name: "setSelection", + name: "setSelectionBefore", target: { type: "primitive", - modifiers: [getModifier(scopeType)], + modifiers: [getModifier({ type: "collectionItem" }, "every")], }, }); }, From 63b17c89831a994b47d136b621d15911d7695db2 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 3 Jan 2026 13:01:43 +0100 Subject: [PATCH 2/2] Assert number of selections --- .../src/suite/performance.vscode.test.ts | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) 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 acf4c6b31f..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: "setSelection", - target: { - type: "primitive", - modifiers: [getModifier(scopeType)], - }, - }); - }, - () => { - return runCursorlessAction({ - name: "setSelectionBefore", - target: { - type: "primitive", - modifiers: [getModifier({ type: "collectionItem" }, "every")], - }, - }); - }, - ); + 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();