MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / takeSnapshot

Function takeSnapshot

src/testUtil/takeSnapshot.ts:24–62  ·  view source on GitHub ↗
(
  thatMark: ThatMark,
  sourceMark: ThatMark,
  excludeFields: string[] = [],
  marks?: SerializedMarks
)

Source from the content-addressed store, hash-verified

22};
23
24export async function takeSnapshot(
25 thatMark: ThatMark,
26 sourceMark: ThatMark,
27 excludeFields: string[] = [],
28 marks?: SerializedMarks
29) {
30 const activeEditor = vscode.window.activeTextEditor!;
31
32 const snapshot: TestCaseSnapshot = {
33 documentContents: activeEditor.document.getText(),
34 selections: activeEditor.selections.map(selectionToPlainObject),
35 };
36
37 if (marks != null) {
38 snapshot.marks = marks;
39 }
40
41 if (!excludeFields.includes("clipboard")) {
42 snapshot.clipboard = await Clipboard.readText();
43 }
44
45 if (!excludeFields.includes("visibleRanges")) {
46 snapshot.visibleRanges = activeEditor.visibleRanges.map(rangeToPlainObject);
47 }
48
49 if (thatMark.exists() && !excludeFields.includes("thatMark")) {
50 snapshot.thatMark = thatMark
51 .get()
52 .map((mark) => selectionToPlainObject(mark.selection));
53 }
54
55 if (sourceMark.exists() && !excludeFields.includes("sourceMark")) {
56 snapshot.sourceMark = sourceMark
57 .get()
58 .map((mark) => selectionToPlainObject(mark.selection));
59 }
60
61 return snapshot;
62}

Callers 3

recordInitialStateMethod · 0.90
recordFinalStateMethod · 0.90
runTestFunction · 0.90

Calls 3

selectionToPlainObjectFunction · 0.90
existsMethod · 0.80
getMethod · 0.80

Tested by 1

runTestFunction · 0.72