([targets]: [TypedSelection[]])
| 65 | } |
| 66 | |
| 67 | async run([targets]: [TypedSelection[]]): Promise<ActionReturnValue> { |
| 68 | const results = flatten( |
| 69 | await runOnTargetsForEachEditor(targets, async (editor, targets) => { |
| 70 | const ranges = this.getRanges(editor, targets); |
| 71 | const editWrappers = this.getEdits(editor, ranges); |
| 72 | const rangeSelections = ranges.map( |
| 73 | ({ range }) => new Selection(range.start, range.end) |
| 74 | ); |
| 75 | |
| 76 | const [editorSelections, copySelections] = |
| 77 | await performEditsAndUpdateSelections( |
| 78 | this.graph.rangeUpdater, |
| 79 | editor, |
| 80 | editWrappers.map((wrapper) => wrapper.edit), |
| 81 | [editor.selections, rangeSelections] |
| 82 | ); |
| 83 | |
| 84 | editor.selections = editorSelections; |
| 85 | editor.revealRange(copySelections[0]); |
| 86 | |
| 87 | let sourceSelections; |
| 88 | if (this.isUp) { |
| 89 | sourceSelections = editWrappers.map((wrapper) => { |
| 90 | const startIndex = |
| 91 | editor.document.offsetAt(wrapper.edit.range.start) + |
| 92 | wrapper.offset; |
| 93 | const endIndex = startIndex + wrapper.length; |
| 94 | return new Selection( |
| 95 | editor.document.positionAt(startIndex), |
| 96 | editor.document.positionAt(endIndex) |
| 97 | ); |
| 98 | }); |
| 99 | } else { |
| 100 | sourceSelections = rangeSelections; |
| 101 | } |
| 102 | |
| 103 | return { |
| 104 | sourceMark: sourceSelections.map((selection) => ({ |
| 105 | editor, |
| 106 | selection, |
| 107 | })), |
| 108 | thatMark: copySelections.map((selection) => ({ |
| 109 | editor, |
| 110 | selection, |
| 111 | })), |
| 112 | }; |
| 113 | }) |
| 114 | ); |
| 115 | |
| 116 | await displayPendingEditDecorationsForSelection( |
| 117 | results.flatMap((result) => result.thatMark), |
| 118 | this.graph.editStyles.justAdded.token |
| 119 | ); |
| 120 | |
| 121 | const sourceMark = results.flatMap((result) => result.sourceMark); |
| 122 | const thatMark = results.flatMap((result) => result.thatMark); |
| 123 | |
| 124 | return { sourceMark, thatMark }; |
nothing calls this directly
no test coverage detected