* Format content that might contain ellipses by using placeholders
(filePath: string, content: string)
| 268 | * Format content that might contain ellipses by using placeholders |
| 269 | */ |
| 270 | async function formatWithPlaceholders(filePath: string, content: string): Promise<string> { |
| 271 | if (!content.includes('…')) { |
| 272 | return formatContent(filePath, content); |
| 273 | } |
| 274 | |
| 275 | // Try using a comment placeholder first (valid in most places) |
| 276 | const commentPlaceholder = '/*__ELLIPSIS__*/'; |
| 277 | // Prettier adds spaces around comments: /* __ELLIPSIS__ */ |
| 278 | const commentRegex = /\/\*\s*__ELLIPSIS__\s*\*\//g; |
| 279 | |
| 280 | try { |
| 281 | const withComments = content.replace(/…/g, commentPlaceholder); |
| 282 | const formatted = await formatContent(filePath, withComments); |
| 283 | return formatted.replace(commentRegex, '…'); |
| 284 | } catch (e) { |
| 285 | // Return original on error |
| 286 | } |
| 287 | |
| 288 | return content; |
| 289 | } |
| 290 | |
| 291 | function applyEllipses(actual: string, expected: string): string { |
| 292 | const changes = diffLines(expected, actual); |
no test coverage detected