(
[targets]: [TypedSelection[]],
replaceWith: string[] | RangeGenerator
)
| 41 | } |
| 42 | |
| 43 | async run( |
| 44 | [targets]: [TypedSelection[]], |
| 45 | replaceWith: string[] | RangeGenerator |
| 46 | ): Promise<ActionReturnValue> { |
| 47 | await displayPendingEditDecorations( |
| 48 | targets, |
| 49 | this.graph.editStyles.pendingModification0 |
| 50 | ); |
| 51 | |
| 52 | const texts = this.getTexts(targets, replaceWith); |
| 53 | |
| 54 | if (targets.length !== texts.length) { |
| 55 | throw new Error("Targets and texts must have same length"); |
| 56 | } |
| 57 | |
| 58 | const edits = zip(targets, texts).map(([target, text]) => ({ |
| 59 | editor: target!.selection.editor, |
| 60 | range: target!.selection.selection, |
| 61 | text: maybeAddDelimiter(text!, target!), |
| 62 | })); |
| 63 | |
| 64 | const thatMark = flatten( |
| 65 | await runForEachEditor( |
| 66 | edits, |
| 67 | (edit) => edit.editor, |
| 68 | async (editor, edits) => { |
| 69 | const [updatedSelections] = await performEditsAndUpdateSelections( |
| 70 | this.graph.rangeUpdater, |
| 71 | editor, |
| 72 | edits, |
| 73 | [targets.map((target) => target.selection.selection)] |
| 74 | ); |
| 75 | |
| 76 | return updatedSelections.map((selection) => ({ |
| 77 | editor, |
| 78 | selection, |
| 79 | })); |
| 80 | } |
| 81 | ) |
| 82 | ); |
| 83 | |
| 84 | return { thatMark }; |
| 85 | } |
| 86 | } |
nothing calls this directly
no test coverage detected