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
31 changes: 29 additions & 2 deletions packages/cursorless-vscode-e2e/src/suite/scopes.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
ScopeSupportFacet,
ScopeType,
PlaintextScopeSupportFacet,
ScopeRangeConfig,
} from "@cursorless/common";
import {
asyncSafety,
Expand Down Expand Up @@ -132,9 +133,10 @@ async function runTest(file: string, languageId: string, facetId: string) {
await openNewEditor(code, { languageId });

const editor = ide.activeTextEditor!;
const updateFixture = shouldUpdateFixtures();

const [outputFixture, numScopes] = ((): [string, number] => {
const config = {
const config: ScopeRangeConfig = {
visibleOnly: false,
scopeType,
};
Expand All @@ -147,6 +149,16 @@ async function runTest(file: string, languageId: string, facetId: string) {
includeNestedTargets: false,
},
);

if (!updateFixture) {
assert.isFalse(
iterationScopes.some((s) =>
s.ranges.some((r) => !s.domain.contains(r.range)),
),
"Iteration range should not contain the domain",
);
}

return [
serializeIterationScopeFixture(code, iterationScopes),
iterationScopes.length,
Expand All @@ -155,10 +167,25 @@ async function runTest(file: string, languageId: string, facetId: string) {

const scopes = scopeProvider.provideScopeRanges(editor, config);

if (!updateFixture) {
assert.isFalse(
scopes.some((s) =>
s.targets.some((t) => !s.domain.contains(t.contentRange)),
),
"Content range should not contain the domain",
);
assert.isFalse(
scopes.some((s) =>
s.targets.some((t) => !s.domain.contains(t.contentRange)),
),
"Content range should not contain the removal range",
);
}

return [serializeScopeFixture(facetId, code, scopes), scopes.length];
})();

if (shouldUpdateFixtures()) {
if (updateFixture) {
await fsp.writeFile(file, outputFixture);
} else {
assert.isAbove(numScopes, 0, "No scopes found");
Expand Down
Loading