mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-26 13:19:42 +00:00
adjustable output height
This commit is contained in:
@@ -234,7 +234,7 @@ export const activate: ActivationFunction<void> = (ctx) => {
|
||||
}
|
||||
span.output-stream.scrollable {
|
||||
overflow-y: scroll;
|
||||
max-height: 400px;
|
||||
max-height: var(--notebook-cell-output-max-height);
|
||||
}
|
||||
span.output-stream.more-above {
|
||||
box-shadow: var(--vscode-scrollbar-shadow) 0 6px 6px -6px inset
|
||||
|
||||
@@ -5,36 +5,35 @@
|
||||
|
||||
import { handleANSIOutput } from './ansi';
|
||||
|
||||
function generateViewMoreElement(outputId: string) {
|
||||
function generateViewMoreElement(outputId: string, adjustableSize: boolean) {
|
||||
const container = document.createElement('span');
|
||||
const first = document.createElement('span');
|
||||
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`;
|
||||
|
||||
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 third = document.createElement('span');
|
||||
third.textContent = '. Enable scrolling in the settings, or open the full output data ';
|
||||
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(first);
|
||||
container.appendChild(second);
|
||||
container.appendChild(third);
|
||||
container.appendChild(forth);
|
||||
return container;
|
||||
}
|
||||
|
||||
export function truncatedArrayOfString(id: string, outputs: string[], linesLimit: number, container: HTMLElement) {
|
||||
const buffer = outputs.join('\n').split(/\r\n|\r|\n/g);
|
||||
export function truncatedArrayOfString(id: string, buffer: string[], linesLimit: number, container: HTMLElement) {
|
||||
const lineCount = buffer.length;
|
||||
|
||||
if (lineCount < linesLimit) {
|
||||
const spanElement = handleANSIOutput(buffer.slice(0, linesLimit).join('\n'));
|
||||
container.appendChild(spanElement);
|
||||
return;
|
||||
}
|
||||
|
||||
container.appendChild(generateViewMoreElement(id));
|
||||
container.appendChild(generateViewMoreElement(id, true));
|
||||
|
||||
const div = document.createElement('div');
|
||||
container.appendChild(div);
|
||||
@@ -50,9 +49,11 @@ export function truncatedArrayOfString(id: string, outputs: string[], linesLimit
|
||||
div2.appendChild(handleANSIOutput(buffer.slice(lineCount - 5).join('\n')));
|
||||
}
|
||||
|
||||
function scrollableArrayOfString(outputs: string[], container: HTMLElement) {
|
||||
function scrollableArrayOfString(id: string, buffer: string[], container: HTMLElement) {
|
||||
container.classList.add('scrollable');
|
||||
container.classList.add('more-below');
|
||||
|
||||
// disposable?
|
||||
container.onscroll = (e) => {
|
||||
const target = e.target as HTMLElement;
|
||||
if (target.scrollTop === 0) {
|
||||
@@ -68,15 +69,27 @@ function scrollableArrayOfString(outputs: string[], container: HTMLElement) {
|
||||
}
|
||||
};
|
||||
|
||||
const buffer = outputs.join('\n').split(/\r\n|\r|\n/g);
|
||||
const spanElement = handleANSIOutput(buffer.slice(0, 5000).join('\n'));
|
||||
container.appendChild(spanElement);
|
||||
if (buffer.length > 5000) {
|
||||
container.appendChild(generateViewMoreElement(id, false));
|
||||
}
|
||||
const div = document.createElement('div');
|
||||
container.appendChild(div);
|
||||
div.appendChild(handleANSIOutput(buffer.slice(0, 5000).join('\n')));
|
||||
}
|
||||
|
||||
export function insertOutput(id: string, outputs: string[], linesLimit: number, scrollable: boolean, container: HTMLElement) {
|
||||
const buffer = outputs.join('\n').split(/\r\n|\r|\n/g);
|
||||
const lineCount = buffer.length;
|
||||
|
||||
if (lineCount < linesLimit) {
|
||||
const spanElement = handleANSIOutput(buffer.join('\n'));
|
||||
container.appendChild(spanElement);
|
||||
return;
|
||||
}
|
||||
|
||||
if (scrollable) {
|
||||
scrollableArrayOfString(outputs, container);
|
||||
scrollableArrayOfString(id, buffer, container);
|
||||
} else {
|
||||
truncatedArrayOfString(id, outputs, linesLimit, container);
|
||||
truncatedArrayOfString(id, buffer, linesLimit, container);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user