* Replaces spans with just the quote delimiters (preserving ' and " characters).
( command: string, spans: Array<[number, number, string, string]>, )
| 192 | * Replaces spans with just the quote delimiters (preserving ' and " characters). |
| 193 | */ |
| 194 | function replaceSpansKeepQuotes( |
| 195 | command: string, |
| 196 | spans: Array<[number, number, string, string]>, |
| 197 | ): string { |
| 198 | if (spans.length === 0) return command |
| 199 | |
| 200 | const sorted = dropContainedSpans(spans).sort((a, b) => b[0] - a[0]) |
| 201 | let result = command |
| 202 | for (const [start, end, open, close] of sorted) { |
| 203 | // Replace content but keep the quote delimiters |
| 204 | result = result.slice(0, start) + open + close + result.slice(end) |
| 205 | } |
| 206 | return result |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Extract quote context from the tree-sitter AST. |
no test coverage detected