Display Windows CRLF as a line break in stored script output
This commit is contained in:
@@ -27,10 +27,11 @@ export function outputText(raw: Uint8Array<ArrayBuffer>, selected: OutputEncodin
|
||||
}
|
||||
}
|
||||
}
|
||||
// Make terminal/control and bidi characters visible. In particular CR cannot
|
||||
// visually overwrite an earlier line; CRLF remains recognizable as such.
|
||||
return { text: decoded.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\ufeff]/g,
|
||||
char => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`), encoding };
|
||||
return { text: visibleControls(decoded.replaceAll('\r\n', '\n')), encoding };
|
||||
}
|
||||
export function visibleControls(text: string): string {
|
||||
return text.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\ufeff]/g,
|
||||
char => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
||||
}
|
||||
function download(raw: Uint8Array<ArrayBuffer>, name: 'stdout' | 'stderr') {
|
||||
const url = URL.createObjectURL(new Blob([raw], { type: 'application/octet-stream' }));
|
||||
|
||||
Reference in New Issue
Block a user