mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Capture all OSC sequences and ESC sequences
Part of microsoft/vscode-copilot#14072
This commit is contained in:
@@ -23,7 +23,14 @@ interface ServerReadyAction {
|
||||
}
|
||||
|
||||
// From src/vs/base/common/strings.ts
|
||||
const CSI_SEQUENCE = /(?:(?:\x1b\[|\x9B)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~])|(:?\x1b\].*?\x07)/g;
|
||||
const CSI_SEQUENCE = /(?:\x1b\[|\x9b)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~]/;
|
||||
const OSC_SEQUENCE = /(?:\x1b\]|\x9d).*?(?:\x1b\\|\x07|\x9c)/;
|
||||
const ESC_SEQUENCE = /\x1b(?:[ #%\(\)\*\+\-\.\/]?[a-zA-Z0-9\|}~@])/;
|
||||
const CONTROL_SEQUENCES = new RegExp('(?:' + [
|
||||
CSI_SEQUENCE.source,
|
||||
OSC_SEQUENCE.source,
|
||||
ESC_SEQUENCE.source,
|
||||
].join('|') + ')', 'g');
|
||||
|
||||
/**
|
||||
* Froms vs/base/common/strings.ts in core
|
||||
@@ -31,7 +38,7 @@ const CSI_SEQUENCE = /(?:(?:\x1b\[|\x9B)[=?>!]?[\d;:]*["$#'* ]?[a-zA-Z@^`{}|~])|
|
||||
*/
|
||||
function removeAnsiEscapeCodes(str: string): string {
|
||||
if (str) {
|
||||
str = str.replace(CSI_SEQUENCE, '');
|
||||
str = str.replace(CONTROL_SEQUENCES, '');
|
||||
}
|
||||
|
||||
return str;
|
||||
|
||||
Reference in New Issue
Block a user