Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}),
),
);
Expand All @@ -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) {
Expand All @@ -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(
Expand All @@ -166,7 +177,7 @@ function testPerformance(thresholdMs: number, action: ActionDescriptor) {
async function testPerformanceCallback(
thresholdMs: number,
callback: () => Promise<unknown>,
beforeCallback?: () => Promise<unknown>,
beforeCallback?: (editor: vscode.TextEditor) => Promise<unknown>,
) {
const editor = await openNewEditor(testData, { languageId: "json" });
// This is the position of the last json key in the document
Expand All @@ -176,7 +187,7 @@ async function testPerformanceCallback(
editor.revealRange(selection);

if (beforeCallback != null) {
await beforeCallback();
await beforeCallback(editor);
}

const start = performance.now();
Expand Down
Loading