| 40 | } |
| 41 | |
| 42 | private getEdits( |
| 43 | editor: TextEditor, |
| 44 | ranges: { range: Range; isParagraph: boolean }[] |
| 45 | ) { |
| 46 | return ranges.map(({ range, isParagraph }) => { |
| 47 | const delimiter = isParagraph ? "\n\n" : "\n"; |
| 48 | let text = editor.document.getText(range); |
| 49 | const length = text.length; |
| 50 | text = this.isUp ? `${delimiter}${text}` : `${text}${delimiter}`; |
| 51 | const newRange = this.isUp |
| 52 | ? new Range(range.end, range.end) |
| 53 | : new Range(range.start, range.start); |
| 54 | return { |
| 55 | edit: { |
| 56 | editor, |
| 57 | range: newRange, |
| 58 | text, |
| 59 | isReplace: this.isUp, |
| 60 | }, |
| 61 | offset: delimiter.length, |
| 62 | length, |
| 63 | }; |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | async run([targets]: [TypedSelection[]]): Promise<ActionReturnValue> { |
| 68 | const results = flatten( |