提交 2b84bca4 编写于 作者: R Robin Munn

Remove incorrect ANSI escape code for LF

ANSI technically doesn't have an escape code for LF, since it just uses the 0x0A character. The regex \xA is incorrect (it should be \x0A) and is being treated as the two-character sequence "xA". But then once we've fixed that, replacing 0x0A with \n in removeAnsiEscapeCodes is a no-op. Better to just remove the str.replace(LF, '\n') call.

Fixes #12608.
上级 3383ef7d
......@@ -531,14 +531,12 @@ export function lcut(text: string, n: number): string {
// Escape codes
// http://en.wikipedia.org/wiki/ANSI_escape_code
const EL = /\x1B\x5B[12]?K/g; // Erase in line
const LF = /\xA/g; // line feed
const COLOR_START = /\x1b\[\d+m/g; // Color
const COLOR_END = /\x1b\[0?m/g; // Color
export function removeAnsiEscapeCodes(str: string): string {
if (str) {
str = str.replace(EL, '');
str = str.replace(LF, '\n');
str = str.replace(COLOR_START, '');
str = str.replace(COLOR_END, '');
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册