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

Method run

src/actions/InsertEmptyLines.ts:51–98  ·  view source on GitHub ↗
([targets]: [TypedSelection[]])

Source from the content-addressed store, hash-verified

49 }
50
51 async run([targets]: [TypedSelection[]]): Promise<ActionReturnValue> {
52 const results = flatten(
53 await runOnTargetsForEachEditor(targets, async (editor, targets) => {
54 const ranges = this.getRanges(targets);
55 const edits = this.getEdits(ranges);
56
57 const [updatedSelections, lineSelections, updatedOriginalSelections] =
58 await performEditsAndUpdateSelections(
59 this.graph.rangeUpdater,
60 editor,
61 edits,
62 [
63 targets.map((target) => target.selection.selection),
64 ranges.map((range) => new Selection(range.start, range.end)),
65 editor.selections,
66 ]
67 );
68
69 editor.selections = updatedOriginalSelections;
70
71 return {
72 thatMark: updatedSelections.map((selection) => ({
73 editor,
74 selection,
75 })),
76 lineSelections: lineSelections.map((selection, index) => ({
77 editor,
78 selection:
79 ranges[index].start.line < editor.document.lineCount - 1
80 ? new Selection(
81 selection.start.translate({ lineDelta: -1 }),
82 selection.end.translate({ lineDelta: -1 })
83 )
84 : selection,
85 })),
86 };
87 })
88 );
89
90 await displayPendingEditDecorationsForSelection(
91 results.flatMap((result) => result.lineSelections),
92 this.graph.editStyles.justAdded.line
93 );
94
95 const thatMark = results.flatMap((result) => result.thatMark);
96
97 return { thatMark };
98 }
99}
100
101export class InsertEmptyLinesAround extends InsertEmptyLines {

Callers

nothing calls this directly

Calls 5

getRangesMethod · 0.95
getEditsMethod · 0.95

Tested by

no test coverage detected