conflictMarkers
The line of the first conflict left marked in a file's text: markers as git writes them, each a line of its own,
seven wide (then a space and a label, or nothing), in order: <<<<<<<, then (with the base's) |||||||, then
=======, then >>>>>>>. Text that only mentions them (a description quoting them, a heading's underline) isn't one.
export function conflictMarkers(text: string): number | undefined { const lines = text.split("\n"); const marker = (l: string, c: string) => l.startsWith(c.repeat(7)) && (l.length === 7 || l[7] === " "); for (let i = 0; i < lines.length; i++) { if (!marker(lines[i]!, "<")) continue; // 0: ours, 1: the base's, 2: theirs let part = 0; for (let j = i + 1; j < lines.length; j++) { const l = lines[j]!; if (marker(l, "<")) break; if (part === 0 && marker(l, "|")) part = 1; else if (part < 2 && l === "=======") part = 2; else if (part === 2 && marker(l, ">")) return i + 1; } } return undefined; }