(
[targets]: [TypedSelection[]],
left: string,
right: string
)
| 30 | } |
| 31 | |
| 32 | async run( |
| 33 | [targets]: [TypedSelection[]], |
| 34 | left: string, |
| 35 | right: string |
| 36 | ): Promise<ActionReturnValue> { |
| 37 | const targetInfos = targets.flatMap((target) => { |
| 38 | const boundary = target.selectionContext.boundary; |
| 39 | |
| 40 | if (boundary == null || boundary.length !== 2) { |
| 41 | throw Error("Target must have an opening and closing delimiter"); |
| 42 | } |
| 43 | |
| 44 | return { |
| 45 | editor: target.selection.editor, |
| 46 | boundary: boundary.map((edge) => |
| 47 | constructSimpleTypedSelection(target.selection.editor, edge) |
| 48 | ), |
| 49 | targetSelection: target.selection.selection, |
| 50 | }; |
| 51 | }); |
| 52 | |
| 53 | await displayPendingEditDecorations( |
| 54 | targetInfos.flatMap(({ boundary }) => boundary), |
| 55 | this.graph.editStyles.pendingModification0 |
| 56 | ); |
| 57 | |
| 58 | const thatMark = flatten( |
| 59 | await runForEachEditor( |
| 60 | targetInfos, |
| 61 | (targetInfo) => targetInfo.editor, |
| 62 | async (editor, targetInfos) => { |
| 63 | const edits = targetInfos.flatMap((targetInfo) => |
| 64 | zip(targetInfo.boundary, [left, right]).map(([target, text]) => ({ |
| 65 | editor, |
| 66 | range: target!.selection.selection, |
| 67 | text: text!, |
| 68 | })) |
| 69 | ); |
| 70 | |
| 71 | const [updatedTargetSelections] = |
| 72 | await performEditsAndUpdateSelections( |
| 73 | this.graph.rangeUpdater, |
| 74 | editor, |
| 75 | edits, |
| 76 | [targetInfos.map((targetInfo) => targetInfo.targetSelection)] |
| 77 | ); |
| 78 | |
| 79 | return updatedTargetSelections.map((selection) => ({ |
| 80 | editor, |
| 81 | selection, |
| 82 | })); |
| 83 | } |
| 84 | ) |
| 85 | ); |
| 86 | |
| 87 | return { thatMark }; |
| 88 | } |
| 89 | } |
nothing calls this directly
no test coverage detected