diff --git a/gui/src/components/logs/parseSpans.test.ts b/gui/src/components/logs/parseSpans.test.ts index d0ac52a3a..cc2646f0b 100644 --- a/gui/src/components/logs/parseSpans.test.ts +++ b/gui/src/components/logs/parseSpans.test.ts @@ -44,7 +44,7 @@ test('parseSpans', () => { }, ]); - check('\u001b[31mRed\u001b[32mGreen\u001b[34mBlue', [ + check('\u001b[31mRed\u001b[32mGreen\u001b[34mBlue\u001b[mReset', [ { foreground: 'rgb(170, 0, 0)', text: 'Red', @@ -57,5 +57,8 @@ test('parseSpans', () => { foreground: 'rgb(0, 0, 170)', text: 'Blue', }, + { + text: 'Reset', + }, ]); }); diff --git a/gui/src/components/logs/parseSpans.ts b/gui/src/components/logs/parseSpans.ts index 75ecaf060..965a975f5 100644 --- a/gui/src/components/logs/parseSpans.ts +++ b/gui/src/components/logs/parseSpans.ts @@ -164,10 +164,13 @@ export const parseSpans = (input: string): Span[] => { } // Handle control sequences. - const control = rest.match(/^\u001b\[([\d;]+)m/); + const control = rest.match(/^\u001b\[([\d;]*)m/); if (control) { emitSpan(); - let codes = control[1].split(';').map((n) => parseInt(n, 10)); + let codes = control[1] + .split(';') + .filter((n) => n !== '') + .map((n) => parseInt(n, 10)); if (codes.length === 0) { codes = [0]; }