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

Method run

src/actions/Wrap.ts:29–125  ·  view source on GitHub ↗
(
    [targets]: [TypedSelection[]],
    left: string,
    right: string
  )

Source from the content-addressed store, hash-verified

27 }
28
29 async run(
30 [targets]: [TypedSelection[]],
31 left: string,
32 right: string
33 ): Promise<ActionReturnValue> {
34 const thatMark = flatten(
35 await runOnTargetsForEachEditor<SelectionWithEditor[]>(
36 targets,
37 async (editor, targets) => {
38 const { document } = editor;
39 const boundaries = targets.map((target) => ({
40 start: new Selection(
41 target.selection.selection.start,
42 target.selection.selection.start
43 ),
44 end: new Selection(
45 target.selection.selection.end,
46 target.selection.selection.end
47 ),
48 }));
49
50 const edits: Edit[] = boundaries.flatMap(({ start, end }) => [
51 {
52 text: left,
53 range: start,
54 },
55 {
56 text: right,
57 range: end,
58 isReplace: true,
59 },
60 ]);
61
62 const delimiterSelectionInfos: FullSelectionInfo[] =
63 boundaries.flatMap(({ start, end }) => {
64 return [
65 getSelectionInfo(
66 document,
67 start,
68 DecorationRangeBehavior.OpenClosed
69 ),
70 getSelectionInfo(
71 document,
72 end,
73 DecorationRangeBehavior.ClosedOpen
74 ),
75 ];
76 });
77
78 const cursorSelectionInfos = editor.selections.map((selection) =>
79 getSelectionInfo(
80 document,
81 selection,
82 DecorationRangeBehavior.ClosedClosed
83 )
84 );
85
86 const thatMarkSelectionInfos = targets.map(

Callers

nothing calls this directly

Calls 3

getSelectionInfoFunction · 0.90
decorationSleepFunction · 0.90

Tested by

no test coverage detected