Commit 80e1ade0 authored by Jose Vargas's avatar Jose Vargas

This fixes the line numbers for the collapsible sections

parent 510b8752
...@@ -132,7 +132,7 @@ export const logLinesParserLegacy = (lines = [], accumulator = []) => ...@@ -132,7 +132,7 @@ export const logLinesParserLegacy = (lines = [], accumulator = []) =>
); );
export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLines = []) => { export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLines = []) => {
let currentLine = previousTraceState?.prevLineCount ?? 0; let currentLineCount = previousTraceState?.prevLineCount ?? 0;
let currentHeader = previousTraceState?.currentHeader; let currentHeader = previousTraceState?.currentHeader;
let isPreviousLineHeader = previousTraceState?.isPreviousLineHeader ?? false; let isPreviousLineHeader = previousTraceState?.isPreviousLineHeader ?? false;
const parsedLines = prevParsedLines.length > 0 ? prevParsedLines : []; const parsedLines = prevParsedLines.length > 0 ? prevParsedLines : [];
...@@ -141,27 +141,27 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi ...@@ -141,27 +141,27 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi
for (let i = 0; i < lines.length; i += 1) { for (let i = 0; i < lines.length; i += 1) {
const line = lines[i]; const line = lines[i];
// First run we can use the current index, later runs we have to retrieve the last number of lines // First run we can use the current index, later runs we have to retrieve the last number of lines
currentLine = previousTraceState?.prevLineCount ? currentLine + 1 : i + 1; currentLineCount = previousTraceState?.prevLineCount ? currentLineCount + 1 : i + 1;
if (line.section_header && !isPreviousLineHeader) { if (line.section_header && !isPreviousLineHeader) {
// If there's no previous line header that means we're at the root of the log // If there's no previous line header that means we're at the root of the log
isPreviousLineHeader = true; isPreviousLineHeader = true;
parsedLines.push(parseHeaderLine(line, currentLine)); parsedLines.push(parseHeaderLine(line, currentLineCount));
currentHeader = { index: parsedLines.length - 1 }; currentHeader = { index: parsedLines.length - 1 };
} else if (line.section_header && isPreviousLineHeader) { } else if (line.section_header && isPreviousLineHeader) {
// If there's a current section, we can't push to the parsedLines array // If there's a current section, we can't push to the parsedLines array
sectionsQueue.push(currentHeader); sectionsQueue.push(currentHeader);
currentHeader = parseHeaderLine(line, currentLine); // Let's parse the incoming header line currentHeader = parseHeaderLine(line, currentLineCount); // Let's parse the incoming header line
} else if (line.section && !line.section_duration) { } else if (line.section && !line.section_duration) {
// We're inside a collapsible section and want to parse a standard line // We're inside a collapsible section and want to parse a standard line
if (currentHeader?.index) { if (currentHeader?.index) {
// If the current section header is only an index, add the line as part of the lines // If the current section header is only an index, add the line as part of the lines
// array of the current collapsible section // array of the current collapsible section
parsedLines[currentHeader.index].lines.push(parseLine(line, currentLine)); parsedLines[currentHeader.index].lines.push(parseLine(line, currentLineCount));
} else { } else {
// Otherwise add it to the innermost collapsible section lines array // Otherwise add it to the innermost collapsible section lines array
currentHeader.lines.push(parseLine(line, currentLine)); currentHeader.lines.push(parseLine(line, currentLineCount));
} }
} else if (line.section && line.section_duration) { } else if (line.section && line.section_duration) {
// NOTE: This marks the end of a section_header // NOTE: This marks the end of a section_header
...@@ -187,7 +187,7 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi ...@@ -187,7 +187,7 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi
currentHeader = previousSection; currentHeader = previousSection;
} }
} else { } else {
parsedLines.push(parseLine(line, currentLine)); parsedLines.push(parseLine(line, currentLineCount));
} }
} }
...@@ -197,7 +197,7 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi ...@@ -197,7 +197,7 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi
isPreviousLineHeader, isPreviousLineHeader,
currentHeader, currentHeader,
sectionsQueue, sectionsQueue,
prevLineCount: lines.length, prevLineCount: currentLineCount,
}, },
}; };
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment