(text, options)
| 266 | } |
| 267 | |
| 268 | function normalizeInputAndOptions(text, options) { |
| 269 | let { cursorOffset, rangeStart, rangeEnd, endOfLine } = normalizeIndexes( |
| 270 | text, |
| 271 | options, |
| 272 | ); |
| 273 | |
| 274 | const hasBOM = text.charAt(0) === BOM; |
| 275 | |
| 276 | if (hasBOM) { |
| 277 | text = text.slice(1); |
| 278 | cursorOffset--; |
| 279 | rangeStart--; |
| 280 | rangeEnd--; |
| 281 | } |
| 282 | |
| 283 | if (endOfLine === "auto") { |
| 284 | endOfLine = guessEndOfLine(text); |
| 285 | } |
| 286 | |
| 287 | // get rid of CR/CRLF parsing |
| 288 | if (text.includes("\r")) { |
| 289 | const countCrlfBefore = (index) => |
| 290 | countEndOfLineCharacters(text.slice(0, Math.max(index, 0)), "\r\n"); |
| 291 | |
| 292 | cursorOffset -= countCrlfBefore(cursorOffset); |
| 293 | rangeStart -= countCrlfBefore(rangeStart); |
| 294 | rangeEnd -= countCrlfBefore(rangeEnd); |
| 295 | |
| 296 | text = normalizeEndOfLine(text); |
| 297 | } |
| 298 | |
| 299 | return { |
| 300 | hasBOM, |
| 301 | text, |
| 302 | options: normalizeIndexes(text, { |
| 303 | ...options, |
| 304 | cursorOffset, |
| 305 | rangeStart, |
| 306 | rangeEnd, |
| 307 | endOfLine, |
| 308 | }), |
| 309 | }; |
| 310 | } |
| 311 | |
| 312 | async function hasPragma(text, options) { |
| 313 | const selectedParser = await resolveParser(options); |
no test coverage detected
searching dependent graphs…