| 1 | /** The replacement text of the first ```suggestion block in a comment, or null when it has none. An empty block suggests deleting the lines. */ |
| 2 | export function extractSuggestion(body |
| 3 | const match = |
| 4 | if (!match) |
| 5 | return match[1] |
| 6 | } |
| 7 | |
| 8 | /** Replaces lines `start` to `end`, 1-based and inclusive, keeping the file's own line endings and its final newline. */ |
| 9 | export function applySuggestion( |
| 10 | content: string, |
| 11 | start: number, |
| 12 | end: number, |
| 13 | replacement: string, |
| 14 | ): string { |
| 15 | const eol = |
| 16 | const lines = |
| 17 | lines.splice( |
| 18 | start - 1, |
| 19 | end - start |
| 20 | ...(replacement === |
| 21 | ); |
| 22 | return lines.join |
| 23 | } |