export function numberTrace(content: string, maxLineLength = 120): string[] { // The backend processor (TraceLineNumberProcessor) numbers lines **after** // splitting any line longer than `maxLineLength` into chunks and indenting // continuation chunks with two leading spaces. To keep `raw_*_ref` mappings // consistent, we reproduce that exact behaviour here. const originalLines = content.split("\n"); const processed: string[] = []; for (const line of originalLines) { if (maxLineLength && line.length > maxLineLength) { const chunks = [] as string[]; for (let i = 0; i < line.length; i += maxLineLength) { chunks.push(line.slice(i, i + maxLineLength)); } if (chunks.length) { // First chunk as-is processed.push(chunks[0]!); // Subsequent chunks get two-space indent so downstream logic can treat // them as "continuation" lines (see isContinuation in the visualizer). for (const chunk of chunks.slice(1)) { processed.push(" " + chunk); } } } else { processed.push(line); } } return processed.map((ln, idx) => ` ${ln}`); }