(originalText, originalOptions)
| 320 | } |
| 321 | |
| 322 | async function formatWithCursor(originalText, originalOptions) { |
| 323 | let { hasBOM, text, options } = normalizeInputAndOptions( |
| 324 | originalText, |
| 325 | await normalizeFormatOptions(originalOptions), |
| 326 | ); |
| 327 | |
| 328 | if ( |
| 329 | (options.rangeStart >= options.rangeEnd && text !== "") || |
| 330 | (options.requirePragma && !(await hasPragma(text, options))) || |
| 331 | (options.checkIgnorePragma && (await hasIgnorePragma(text, options))) |
| 332 | ) { |
| 333 | return { |
| 334 | formatted: originalText, |
| 335 | cursorOffset: originalOptions.cursorOffset, |
| 336 | comments: [], |
| 337 | }; |
| 338 | } |
| 339 | |
| 340 | let result; |
| 341 | |
| 342 | if (options.rangeStart > 0 || options.rangeEnd < text.length) { |
| 343 | result = await formatRange(text, options); |
| 344 | } else { |
| 345 | if ( |
| 346 | !options.requirePragma && |
| 347 | options.insertPragma && |
| 348 | options.printer.insertPragma && |
| 349 | !(await hasPragma(text, options)) |
| 350 | ) { |
| 351 | text = options.printer.insertPragma(text); |
| 352 | } |
| 353 | result = await coreFormat(text, options); |
| 354 | } |
| 355 | |
| 356 | if (hasBOM) { |
| 357 | result.formatted = BOM + result.formatted; |
| 358 | |
| 359 | if (result.cursorOffset >= 0) { |
| 360 | result.cursorOffset++; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | return result; |
| 365 | } |
| 366 | |
| 367 | async function parse(originalText, originalOptions, devOptions) { |
| 368 | const { text, options } = normalizeInputAndOptions( |
no test coverage detected
searching dependent graphs…