From 680989bf42b49144bf92870c9671768c3f6ce590 Mon Sep 17 00:00:00 2001 From: danielfrankcom Date: Sun, 27 May 2018 14:49:26 -0700 Subject: [PATCH] Simplifying ANSI logic when no sequence found --- .../parts/debug/browser/debugANSIHandling.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/debugANSIHandling.ts b/src/vs/workbench/parts/debug/browser/debugANSIHandling.ts index fc5e15e4466..07fe64ce7a6 100644 --- a/src/vs/workbench/parts/debug/browser/debugANSIHandling.ts +++ b/src/vs/workbench/parts/debug/browser/debugANSIHandling.ts @@ -20,6 +20,8 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector): HTML while (currentPos < textLength) { + let sequenceFound: boolean = false; + // Potentially an ANSI escape sequence. // See http://ascii-table.com/ansi-escape-sequences.php & https://en.wikipedia.org/wiki/ANSI_escape_code if (text.charCodeAt(currentPos) === 27 && text.charAt(currentPos + 1) === '[') { @@ -28,7 +30,6 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector): HTML currentPos += 2; // Ignore 'Esc[' as it's in every sequence. let ansiSequence: string = ''; - let sequenceFound: boolean = false; while (currentPos < textLength) { const char: string = text.charAt(currentPos); @@ -81,18 +82,13 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector): HTML // Unsupported sequence so simply hide it. } + } else { + currentPos = startPos; } - if (sequenceFound === false) { - /* - * Reached end of text without ending the escape sequence, - * or given sequence is currently unsupported. In either - * case, treat sequence as regular text. - */ - currentPos = startPos + 1; - } + } - } else { + if (sequenceFound === false) { buffer += text.charAt(currentPos); currentPos++; } -- GitLab