([targets]: [
TypedSelection[],
TypedSelection[]
])
| 19 | } |
| 20 | |
| 21 | async run([targets]: [ |
| 22 | TypedSelection[], |
| 23 | TypedSelection[] |
| 24 | ]): Promise<ActionReturnValue> { |
| 25 | const originalEditor = window.activeTextEditor; |
| 26 | const editor = ensureSingleEditor(targets); |
| 27 | |
| 28 | if (originalEditor !== editor) { |
| 29 | await focusEditor(editor); |
| 30 | } |
| 31 | |
| 32 | const singleLineTargets = targets.filter( |
| 33 | (target) => target.selection.selection.isSingleLine |
| 34 | ); |
| 35 | const multiLineTargets = targets.filter( |
| 36 | (target) => !target.selection.selection.isSingleLine |
| 37 | ); |
| 38 | // Don't mix multi and single line targets. |
| 39 | // This is probably the result of an "every" command |
| 40 | // and folding the single line targets will fold the parent as well |
| 41 | const selectedTargets = multiLineTargets.length |
| 42 | ? multiLineTargets |
| 43 | : singleLineTargets; |
| 44 | |
| 45 | await commands.executeCommand(this.command, { |
| 46 | levels: 1, |
| 47 | direction: "down", |
| 48 | selectionLines: selectedTargets.map( |
| 49 | (target) => target.selection.selection.start.line |
| 50 | ), |
| 51 | }); |
| 52 | |
| 53 | // If necessary focus back original editor |
| 54 | if (originalEditor != null && originalEditor !== editor) { |
| 55 | await focusEditor(originalEditor); |
| 56 | } |
| 57 | |
| 58 | return { |
| 59 | thatMark: targets.map((target) => target.selection), |
| 60 | }; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | export class Fold extends FoldAction { |
nothing calls this directly
no test coverage detected