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

Method run

src/actions/Deselect.ts:20–40  ·  view source on GitHub ↗
([targets]: [TypedSelection[]])

Source from the content-addressed store, hash-verified

18 }
19
20 async run([targets]: [TypedSelection[]]): Promise<ActionReturnValue> {
21 await runOnTargetsForEachEditor(targets, async (editor, targets) => {
22 // Remove selections with a non-empty intersection
23 const newSelections = editor.selections.filter(
24 (selection) =>
25 !targets.some((target) => {
26 const intersection =
27 target.selection.selection.intersection(selection);
28 return intersection && (!intersection.isEmpty || selection.isEmpty);
29 })
30 );
31 // The editor requires at least one selection. Keep "primary" selection active
32 editor.selections = newSelections.length
33 ? newSelections
34 : [new Selection(editor.selection.active, editor.selection.active)];
35 });
36
37 return {
38 thatMark: targets.map((target) => target.selection),
39 };
40 }
41}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected