mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
css change to scroll output
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import type { ActivationFunction, OutputItem, RendererContext } from 'vscode-notebook-renderer';
|
||||
import { truncatedArrayOfString } from './textHelper';
|
||||
import { insertOutput, truncatedArrayOfString } from './textHelper';
|
||||
|
||||
interface IDisposable {
|
||||
dispose(): void;
|
||||
@@ -153,7 +153,7 @@ function renderError(outputInfo: OutputItem, container: HTMLElement, ctx: Render
|
||||
container.classList.add('error');
|
||||
}
|
||||
|
||||
function renderStream(outputInfo: OutputItem, container: HTMLElement, error: boolean, ctx: RendererContext<void> & { readonly settings: { readonly lineLimit: number } }): void {
|
||||
function renderStream(outputInfo: OutputItem, container: HTMLElement, error: boolean, ctx: RendererContext<void> & { readonly settings: { readonly lineLimit: number; readonly outputScrolling: boolean } }): void {
|
||||
const outputContainer = container.parentElement;
|
||||
if (!outputContainer) {
|
||||
// should never happen
|
||||
@@ -170,7 +170,7 @@ function renderStream(outputInfo: OutputItem, container: HTMLElement, error: boo
|
||||
const text = outputInfo.text();
|
||||
|
||||
const element = document.createElement('span');
|
||||
truncatedArrayOfString(outputInfo.id, [text], ctx.settings.lineLimit, element);
|
||||
insertOutput(outputInfo.id, [text], ctx.settings.lineLimit, true, element);
|
||||
outputElement.appendChild(element);
|
||||
return;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ function renderStream(outputInfo: OutputItem, container: HTMLElement, error: boo
|
||||
element.classList.add('output-stream');
|
||||
|
||||
const text = outputInfo.text();
|
||||
truncatedArrayOfString(outputInfo.id, [text], ctx.settings.lineLimit, element);
|
||||
insertOutput(outputInfo.id, [text], ctx.settings.lineLimit, true, element);
|
||||
while (container.firstChild) {
|
||||
container.removeChild(container.firstChild);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ export const activate: ActivationFunction<void> = (ctx) => {
|
||||
const htmlHooks = new Set<HtmlRenderingHook>();
|
||||
const jsHooks = new Set<JavaScriptRenderingHook>();
|
||||
|
||||
const latestContext = ctx as (RendererContext<void> & { readonly settings: { readonly lineLimit: number } });
|
||||
const latestContext = ctx as (RendererContext<void> & { readonly settings: { readonly lineLimit: number; readonly outputScrolling: boolean } });
|
||||
|
||||
const style = document.createElement('style');
|
||||
style.textContent = `
|
||||
@@ -225,6 +225,9 @@ export const activate: ActivationFunction<void> = (ctx) => {
|
||||
}
|
||||
span.output-stream {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
overflow-y: var(--notebook-output-overflow-y);
|
||||
max-height: 500px;
|
||||
}
|
||||
.output-plaintext .code-bold,
|
||||
.output-stream .code-bold,
|
||||
|
||||
@@ -13,9 +13,9 @@ function generateViewMoreElement(outputId: string) {
|
||||
second.textContent = 'size limit';
|
||||
second.href = `command:workbench.action.openSettings?%5B%22notebook.output.textLineLimit%22%5D`;
|
||||
const third = document.createElement('span');
|
||||
third.textContent = '. Open the full output data';
|
||||
third.textContent = '. Enable scrolling in the settings, or open the full output data ';
|
||||
const forth = document.createElement('a');
|
||||
forth.textContent = ' in a text editor';
|
||||
forth.textContent = 'in a text editor';
|
||||
forth.href = `command:workbench.action.openLargeOutput?${outputId}`;
|
||||
container.appendChild(first);
|
||||
container.appendChild(second);
|
||||
@@ -49,3 +49,17 @@ export function truncatedArrayOfString(id: string, outputs: string[], linesLimit
|
||||
container.appendChild(div2);
|
||||
div2.appendChild(handleANSIOutput(buffer.slice(lineCount - 5).join('\n')));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
export function insertOutput(id: string, outputs: string[], linesLimit: number, scrollable: boolean, container: HTMLElement) {
|
||||
if (scrollable) {
|
||||
scrollableArrayOfString(outputs, container);
|
||||
} else {
|
||||
truncatedArrayOfString(id, outputs, linesLimit, container);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user