From e156de1b98cdf16afad2c6d2ec546a148c0dc054 Mon Sep 17 00:00:00 2001 From: Ian Sanders Date: Thu, 14 Mar 2019 12:10:49 -0400 Subject: [PATCH] Remove existing ANSI colours when adding new ones Avoids color conflicts by removing previous colors when new ones added. Fixes #70416. --- .../debug/browser/debugANSIHandling.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/debugANSIHandling.ts b/src/vs/workbench/contrib/debug/browser/debugANSIHandling.ts index 9894e465b20..df8f1dc2b3b 100644 --- a/src/vs/workbench/contrib/debug/browser/debugANSIHandling.ts +++ b/src/vs/workbench/contrib/debug/browser/debugANSIHandling.ts @@ -72,16 +72,20 @@ export function handleANSIOutput(text: string, linkDetector: LinkDetector): HTML styleNames.push('code-italic'); } else if (code === 4) { styleNames.push('code-underline'); - } else if ((code >= 30 && code <= 37) || (code >= 90 && code <= 97)) { - styleNames.push('code-foreground-' + code); - } else if (code === 39) { - // Remove all foreground colour codes + } else if (code === 39 || (code >= 30 && code <= 37) || (code >= 90 && code <= 97)) { + // Remove all previous foreground colour codes styleNames = styleNames.filter(style => !style.match(/^code-foreground-\d+$/)); - } else if ((code >= 40 && code <= 47) || (code >= 100 && code <= 107)) { - styleNames.push('code-background-' + code); - } else if (code === 49) { - // Remove all background colour codes + + if (code !== 39) { + styleNames.push('code-foreground-' + code); + } + } else if (code === 49 || (code >= 40 && code <= 47) || (code >= 100 && code <= 107)) { + // Remove all previous background colour codes styleNames = styleNames.filter(style => !style.match(/^code-background-\d+$/)); + + if (code !== 49) { + styleNames.push('code-background-' + code); + } } } -- GitLab