([targets]: [TypedSelection[]])
| 20 | } |
| 21 | |
| 22 | async run([targets]: [TypedSelection[]]): Promise<ActionReturnValue> { |
| 23 | const selectionGroups = groupBy( |
| 24 | targets, |
| 25 | (t: TypedSelection) => t.selection.editor |
| 26 | ); |
| 27 | |
| 28 | const lines = Array.from(selectionGroups, ([editor, targets]) => { |
| 29 | return { lineNumber: getLineNumber(targets, this.at), editor }; |
| 30 | }); |
| 31 | |
| 32 | const originalEditor = window.activeTextEditor; |
| 33 | |
| 34 | for (const lineWithEditor of lines) { |
| 35 | // For reveal line to the work we have to have the correct editor focused |
| 36 | if (lineWithEditor.editor !== window.activeTextEditor) { |
| 37 | await focusEditor(lineWithEditor.editor); |
| 38 | } |
| 39 | await commands.executeCommand("revealLine", { |
| 40 | lineNumber: lineWithEditor.lineNumber, |
| 41 | at: this.at, |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | // If necessary focus back original editor |
| 46 | if (originalEditor != null && originalEditor !== window.activeTextEditor) { |
| 47 | await focusEditor(originalEditor); |
| 48 | } |
| 49 | |
| 50 | const decorationSelections = targets |
| 51 | .map((target) => target.selection) |
| 52 | .filter((selection) => { |
| 53 | const visibleRanges = selection.editor.visibleRanges; |
| 54 | const startLine = visibleRanges[0].start.line; |
| 55 | const endLine = visibleRanges[visibleRanges.length - 1].end.line; |
| 56 | // Don't show decorations for selections that are larger than the visible range |
| 57 | return ( |
| 58 | selection.selection.start.line > startLine || |
| 59 | selection.selection.end.line < endLine || |
| 60 | (selection.selection.start.line === startLine && |
| 61 | selection.selection.end.line === endLine) |
| 62 | ); |
| 63 | }); |
| 64 | |
| 65 | await displayPendingEditDecorationsForSelection( |
| 66 | decorationSelections, |
| 67 | this.graph.editStyles.referenced.line |
| 68 | ); |
| 69 | |
| 70 | return { |
| 71 | thatMark: targets.map((target) => target.selection), |
| 72 | }; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | export class ScrollToTop extends Scroll { |
nothing calls this directly
no test coverage detected