Skip to content

Commit e8564ad

Browse files
committed
More docs
1 parent bc4c816 commit e8564ad

33 files changed

+521
-304
lines changed

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export { default as DefaultMap } from "./util/DefaultMap";
5252
export * from "./types/GeneralizedRange";
5353
export * from "./types/RangeOffsets";
5454
export * from "./util/omitByDeep";
55+
export * from "./util/range";
5556
export * from "./testUtil/isTesting";
5657
export * from "./testUtil/testConstants";
5758
export * from "./testUtil/getFixturePaths";

packages/common/src/util/range.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { range as lodashRange } from "lodash";
2+
import { Range } from "../types/Range";
3+
import { TextEditor } from "../types/TextEditor";
4+
5+
/**
6+
* @param editor The editor containing the range
7+
* @param range The range to get the line ranges for
8+
* @returns A list of ranges, one for each line in the given range, with the
9+
* first and last ranges trimmed to the start and end of the given range.
10+
*/
11+
export function getLineRanges(editor: TextEditor, range: Range): Range[] {
12+
const { document } = editor;
13+
const lineRanges = lodashRange(range.start.line, range.end.line + 1).map(
14+
(lineNumber) => document.lineAt(lineNumber).range,
15+
);
16+
lineRanges[0] = lineRanges[0].with(range.start);
17+
lineRanges[lineRanges.length - 1] = lineRanges[lineRanges.length - 1].with(
18+
undefined,
19+
range.end,
20+
);
21+
return lineRanges;
22+
}

packages/cursorless-vscode-e2e/src/suite/scopeVisualizer/checkAndResetFakes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import * as sinon from "sinon";
33
import {
44
createDecorationTypeCallToPlainObject,
55
setDecorationsCallToPlainObject,
6-
} from "./toPlainObject";
6+
} from "./spyCallsToPlainObject";
77
import { Fakes, ExpectedArgs } from "./scopeVisualizerTest.types";
88

99
export function checkAndResetFakes(fakes: Fakes, expected: ExpectedArgs) {
10-
const actual = getAndResetFakes(fakes);
10+
const actual = getSpyCallsAndResetFakes(fakes);
1111
assert.deepStrictEqual(actual, expected, JSON.stringify(actual));
1212
}
1313

14-
export function getAndResetFakes({
14+
function getSpyCallsAndResetFakes({
1515
createTextEditorDecorationType,
1616
setDecorations,
1717
dispose,

packages/cursorless-vscode-e2e/src/suite/scopeVisualizer/colorConfig.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { ScopeVisualizerColorConfig } from "@cursorless/vscode-common";
22

3+
/**
4+
* Fake color config to use for testing. We use an alpha of 50% and try to use
5+
* different rgb channels where possible to make it easier to see what happens
6+
* when we blend colors.
7+
*/
38
export const COLOR_CONFIG: ScopeVisualizerColorConfig = {
49
dark: {
510
content: {

packages/cursorless-vscode-e2e/src/suite/scopeVisualizer/injectFakes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "./scopeVisualizerTest.types";
1010

1111
export async function injectFakes(): Promise<Fakes> {
12-
const { vscodeApi: vscodeApi } = (await getCursorlessApi()).testHelpers!;
12+
const { vscodeApi } = (await getCursorlessApi()).testHelpers!;
1313

1414
const dispose = sinon.fake<[number], void>();
1515

Loading

packages/cursorless-vscode-e2e/src/suite/scopeVisualizer/runBasicMultilineContentTest.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import { checkAndResetFakes } from "./checkAndResetFakes";
44
import { injectFakes } from "./injectFakes";
55
import { ExpectedArgs } from "./scopeVisualizerTest.types";
66

7+
/**
8+
* Tests that the scope visualizer works with multiline content, by
9+
* ensuring that the correct decorations are applied so that it looks
10+
* as follows:
11+
*
12+
* ![basic multiline content](./runBasicMultilineContentTest.png)
13+
*/
714
export async function runBasicMultilineContentTest() {
815
await openNewEditor(contents, {
916
languageId: "typescript",
Loading

packages/cursorless-vscode-e2e/src/suite/scopeVisualizer/runBasicRemovalTest.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { checkAndResetFakes } from "./checkAndResetFakes";
44
import { injectFakes } from "./injectFakes";
55
import { ExpectedArgs } from "./scopeVisualizerTest.types";
66

7+
/**
8+
* Tests that the scope visualizer works with removal ranges, by ensuring that
9+
* the correct decorations are applied so that it looks as follows:
10+
*
11+
* ![basic removal](./runBasicRemovalTest.png)
12+
*/
713
export async function runBasicRemovalTest() {
814
await openNewEditor("aaa bbb");
915

Loading

0 commit comments

Comments
 (0)