fix(javascript): count all source line terminators

This commit is contained in:
Kaoru0822
2026-10-05 23:49:27 -07:00
parent b6c21b1db5
commit 03bc6d36db
3 changed files with 111 additions and 1 deletions
@@ -386,7 +386,8 @@ export const sourceRangesEqual = (
const pointForOffset = (source: string, offset: number) => {
const before = source.slice(0, offset);
const lines = before.split("\n");
// Match JavaScript line terminators, treating CRLF as a single newline.
const lines = before.split(/\r\n|[\n\r\u2028\u2029]/u);
return { line: lines.length, column: lines.at(-1)?.length ?? 0 };
};