mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 08:38:56 +01:00
updated stream output to consolidate correctly
This commit is contained in:
@@ -7,35 +7,50 @@ import { handleANSIOutput } from './ansi';
|
||||
|
||||
export const scrollableClass = 'scrollable';
|
||||
|
||||
function generateViewMoreElement(outputId: string, adjustableSize: boolean) {
|
||||
function generateViewMoreElement(outputId: string) {
|
||||
const container = document.createElement('span');
|
||||
const first = document.createElement('span');
|
||||
first.textContent = 'Output exceeds the ';
|
||||
|
||||
if (adjustableSize) {
|
||||
first.textContent = 'Output exceeds the ';
|
||||
const second = document.createElement('a');
|
||||
second.textContent = 'size limit';
|
||||
second.href = `command:workbench.action.openSettings?%5B%22notebook.output.textLineLimit%22%5D`;
|
||||
container.appendChild(first);
|
||||
container.appendChild(second);
|
||||
} else {
|
||||
first.textContent = 'Output exceeds the maximium size limit';
|
||||
container.appendChild(first);
|
||||
}
|
||||
const second = document.createElement('a');
|
||||
second.textContent = 'size limit';
|
||||
second.href = `command:workbench.action.openSettings?%5B%22notebook.output.textLineLimit%22%5D`;
|
||||
container.appendChild(first);
|
||||
container.appendChild(second);
|
||||
|
||||
const third = document.createElement('span');
|
||||
third.textContent = '. Open the full output data ';
|
||||
|
||||
const forth = document.createElement('a');
|
||||
forth.textContent = 'in a text editor';
|
||||
forth.href = `command:workbench.action.openLargeOutput?${outputId}`;
|
||||
container.appendChild(third);
|
||||
container.appendChild(forth);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
function generateNestedViewAllElement(outputId: string) {
|
||||
const container = document.createElement('span');
|
||||
const prefix = document.createElement('span');
|
||||
prefix.innerText = '... (View full content in a ';
|
||||
container.append(prefix);
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.textContent = 'text editor';
|
||||
link.href = `command:workbench.action.openLargeOutput?${outputId}`;
|
||||
container.append(link);
|
||||
|
||||
const postfix = document.createElement('span');
|
||||
prefix.innerText = ')\n';
|
||||
container.append(postfix);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
function truncatedArrayOfString(id: string, buffer: string[], linesLimit: number, container: HTMLElement, trustHtml: boolean) {
|
||||
const lineCount = buffer.length;
|
||||
container.parentNode!.append(generateViewMoreElement(id, true));
|
||||
container.appendChild(generateViewMoreElement(id));
|
||||
|
||||
container.appendChild(handleANSIOutput(buffer.slice(0, linesLimit - 5).join('\n'), trustHtml));
|
||||
|
||||
@@ -48,29 +63,28 @@ function truncatedArrayOfString(id: string, buffer: string[], linesLimit: number
|
||||
}
|
||||
|
||||
function scrollableArrayOfString(id: string, buffer: string[], container: HTMLElement, trustHtml: boolean) {
|
||||
container.classList.add(scrollableClass);
|
||||
|
||||
if (buffer.length > 5000) {
|
||||
container.parentNode!.append(generateViewMoreElement(id, false));
|
||||
container.parentNode!.append(generateNestedViewAllElement(id));
|
||||
}
|
||||
|
||||
container.appendChild(handleANSIOutput(buffer.slice(0, 5000).join('\n'), trustHtml));
|
||||
container.appendChild(handleANSIOutput(buffer.slice(-5000).join('\n'), trustHtml));
|
||||
}
|
||||
|
||||
export function insertOutput(id: string, outputs: string[], linesLimit: number, scrollable: boolean, trustHtml: boolean) {
|
||||
const element = document.createElement('div');
|
||||
const buffer = outputs.join('\n').split(/\r\n|\r|\n/g);
|
||||
|
||||
if (scrollable) {
|
||||
scrollableArrayOfString(id, buffer, element, trustHtml);
|
||||
}
|
||||
|
||||
const lineCount = buffer.length;
|
||||
|
||||
if (lineCount < linesLimit) {
|
||||
if (lineCount <= linesLimit) {
|
||||
const spanElement = handleANSIOutput(buffer.join('\n'), trustHtml);
|
||||
element.appendChild(spanElement);
|
||||
} else {
|
||||
if (scrollable) {
|
||||
scrollableArrayOfString(id, buffer, element, trustHtml);
|
||||
} else {
|
||||
truncatedArrayOfString(id, buffer, linesLimit, element, trustHtml);
|
||||
}
|
||||
truncatedArrayOfString(id, buffer, linesLimit, element, trustHtml);
|
||||
}
|
||||
|
||||
return element;
|
||||
|
||||
Reference in New Issue
Block a user