@@ -138,23 +161,27 @@
function processTrace(trace, otherTrace, resultId) {
const lines = trace.trim().split('\n');
const otherLines = otherTrace.trim().split('\n');
- let html = '';
+ let contentHtml = '';
+ let lineNumbersHtml = '';
let indentLevel = 0;
let blockStartLine = -1;
+ // Generate line numbers
+ for (let i = 1; i <= lines.length; i++) {
+ lineNumbersHtml += `${i}\n`;
+ }
+
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
const shouldHighlight = !otherLines.some(otherLine => otherLine.trim() === line);
const highlightClass = shouldHighlight ? 'highlight' : '';
- // Check if this line is the start of a block that has content
const isBlockStart = line.endsWith('{') && i < lines.length - 1;
if (isBlockStart) {
blockStartLine = i;
- // Start of a function block with content
const functionName = line;
- html += `
+ contentHtml += `
▼${functionName}
@@ -162,25 +189,23 @@
`;
indentLevel++;
} else if (line.includes('}')) {
- // End of a block
if (indentLevel > 0) {
indentLevel--;
- html += `
${line}
`;
+ contentHtml += `
${line}
`;
} else {
- html += `
${line}
`;
+ contentHtml += `
${line}
`;
}
} else {
- // Regular line or a line ending with { at the end of input
const isLastLineBlock = line.endsWith('{') && i === lines.length - 1;
if (isLastLineBlock) {
- html += `
${line}
`;
+ contentHtml += `
${line}
`;
} else {
- html += `
${line}
`;
+ contentHtml += `
${line}
`;
}
}
}
- return html;
+ return `
${lineNumbersHtml}
${contentHtml}
`;
}
function initializeCollapsible(containerId) {