Fix removeAnsiEscapeCodes for escape sequence after : (#211886)

* Fix removeAnsiEscapeCodes for escape sequence after :
Fix #209937

* And in debug-server-ready
This commit is contained in:
Rob Lourens 2024-05-03 03:33:24 +00:00 committed by GitHub
parent 2bdbf82fe7
commit f8b115947e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -22,8 +22,8 @@ interface ServerReadyAction {
killOnServerStop?: boolean;
}
// Escape codes, compiled from https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
const CSI_SEQUENCE = /(:?\x1b\[|\x9B)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~]/g;
// From src/vs/base/common/strings.ts
const CSI_SEQUENCE = /(?:(?:\x1b\[|\x9B)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~])|(:?\x1b\].*?\x07)/g;
/**
* Froms vs/base/common/strings.ts in core

View File

@ -766,7 +766,7 @@ export function lcut(text: string, n: number, prefix = '') {
// Escape codes, compiled from https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
// Plus additional markers for custom `\x1b]...\x07` instructions.
const CSI_SEQUENCE = /(:?(:?\x1b\[|\x9B)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~])|(:?\x1b\].*?\x07)/g;
const CSI_SEQUENCE = /(?:(?:\x1b\[|\x9B)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~])|(:?\x1b\].*?\x07)/g;
/** Iterates over parts of a string with CSI sequences */
export function* forAnsiStringParts(str: string) {

View File

@ -536,6 +536,11 @@ suite('Strings', () => {
`expect to forAnsiStringParts ${JSON.stringify(sequence)}`
);
}
// #209937
assert.strictEqual(
strings.removeAnsiEscapeCodes(`localhost:\x1b[31m1234`),
'localhost:1234',);
});
test('removeAnsiEscapeCodesFromPrompt', () => {