function splitDocumentIntoLines()

in src/desktop/ci/ansi_decoration_provider.ts [81:104]


function splitDocumentIntoLines(document: string): string[] {
  const lines = document.split('\n');
  const [firstLine] = lines;

  const timestampLength = firstLine?.indexOf(' ') ?? 0;
  const headerLength = timestampLength + 5;
  // If the document does not contain timestamp information, return the lines as-is
  if (!firstLine || Number.isNaN(Date.parse(firstLine.substring(0, timestampLength - 1)))) {
    return lines;
  }

  for (let i = 0; i < lines.length; i++) {
    // Remove the header from each line
    lines[i] = lines[i].substring(headerLength);

    // Read the append flag for every line after the current line
    while (i < lines.length - 1 && lines[i + 1][headerLength - 1] === '+') {
      lines[i] += lines[i + 1].substring(headerLength);
      lines.splice(i + 1, 1);
    }
  }

  return lines;
}