提交 e156de1b 编写于 作者: I Ian Sanders

Remove existing ANSI colours when adding new ones

Avoids color conflicts by removing previous colors when new ones added.
Fixes #70416.
上级 b4d347d9
......@@ -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);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册