mirror of
https://github.com/Microsoft/vscode
synced 2024-08-25 03:56:03 +00:00
fix #128765.
This commit is contained in:
parent
c5720ec57b
commit
955a1aca9a
|
@ -247,6 +247,11 @@
|
|||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.monaco-workbench .notebookOverlay .output > div.foreground .output-stream pre,
|
||||
.monaco-workbench .notebookOverlay .output > div.foreground .output-plaintext pre {
|
||||
font-family: var(--monaco-monospace-font);
|
||||
}
|
||||
|
||||
.monaco-workbench .notebookOverlay .output > div.foreground.error .output-stream {
|
||||
color: red; /*TODO@rebornix theme color*/
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEd
|
|||
import { isCompositeNotebookEditorInput, NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
|
||||
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
|
||||
import { NotebookService } from 'vs/workbench/contrib/notebook/browser/notebookServiceImpl';
|
||||
import { CellKind, CellToolbarLocation, CellToolbarVisibility, CellUri, DisplayOrderKey, UndoRedoPerCell, IResolvedNotebookEditorModel, NotebookDocumentBackupData, NotebookTextDiffEditorPreview, NotebookWorkingCopyTypeIdentifier, ShowCellStatusBar, CompactView, FocusIndicator, InsertToolbarLocation, GlobalToolbar, ConsolidatedOutputButton, ShowFoldingControls, DragAndDropEnabled, NotebookCellEditorOptionsCustomizations, ConsolidatedRunButton } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { CellKind, CellToolbarLocation, CellToolbarVisibility, CellUri, DisplayOrderKey, UndoRedoPerCell, IResolvedNotebookEditorModel, NotebookDocumentBackupData, NotebookTextDiffEditorPreview, NotebookWorkingCopyTypeIdentifier, ShowCellStatusBar, CompactView, FocusIndicator, InsertToolbarLocation, GlobalToolbar, ConsolidatedOutputButton, ShowFoldingControls, DragAndDropEnabled, NotebookCellEditorOptionsCustomizations, ConsolidatedRunButton, TextOutputLineLimit } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
|
||||
import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService';
|
||||
|
@ -724,6 +724,11 @@ configurationRegistry.registerConfiguration({
|
|||
default: false,
|
||||
tags: ['notebookLayout']
|
||||
},
|
||||
[TextOutputLineLimit]: {
|
||||
description: nls.localize('notebook.textOutputLineLimit', "Control how many lines of text in a text output is rendered."),
|
||||
type: 'number',
|
||||
default: 30
|
||||
},
|
||||
[NotebookCellEditorOptionsCustomizations]: editorOptionsCustomizationSchema
|
||||
}
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ import { Mimes } from 'vs/base/common/mime';
|
|||
import { dirname } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { MarkdownRenderer } from 'vs/editor/browser/core/markdownRenderer';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
|
@ -18,7 +19,7 @@ import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector';
|
|||
import { ICellOutputViewModel, ICommonNotebookEditor, IOutputTransformContribution as IOutputRendererContribution, IRenderOutput, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { OutputRendererRegistry } from 'vs/workbench/contrib/notebook/browser/view/output/rendererRegistry';
|
||||
import { truncatedArrayOfString } from 'vs/workbench/contrib/notebook/browser/view/output/transforms/textHelper';
|
||||
import { IOutputItemDto } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { IOutputItemDto, TextOutputLineLimit } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
||||
|
||||
class JavaScriptRendererContrib extends Disposable implements IOutputRendererContribution {
|
||||
|
@ -63,6 +64,7 @@ class StreamRendererContrib extends Disposable implements IOutputRendererContrib
|
|||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@IThemeService private readonly themeService: IThemeService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
@ -72,7 +74,8 @@ class StreamRendererContrib extends Disposable implements IOutputRendererContrib
|
|||
|
||||
const text = getStringValue(item);
|
||||
const contentNode = DOM.$('span.output-stream');
|
||||
truncatedArrayOfString(notebookUri, output.cellViewModel, contentNode, [text], linkDetector, this.openerService, this.themeService);
|
||||
const lineLimit = this.configurationService.getValue<number>(TextOutputLineLimit) ?? 30;
|
||||
truncatedArrayOfString(notebookUri, output.cellViewModel, Math.max(lineLimit, 6), contentNode, [text], linkDetector, this.openerService, this.themeService);
|
||||
container.appendChild(contentNode);
|
||||
|
||||
return { type: RenderOutputType.Mainframe };
|
||||
|
@ -161,6 +164,7 @@ class PlainTextRendererContrib extends Disposable implements IOutputRendererCont
|
|||
public notebookEditor: ICommonNotebookEditor,
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@IThemeService private readonly themeService: IThemeService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService
|
||||
) {
|
||||
super();
|
||||
|
@ -171,7 +175,8 @@ class PlainTextRendererContrib extends Disposable implements IOutputRendererCont
|
|||
|
||||
const str = getStringValue(item);
|
||||
const contentNode = DOM.$('.output-plaintext');
|
||||
truncatedArrayOfString(notebookUri, output.cellViewModel, contentNode, [str], linkDetector, this.openerService, this.themeService);
|
||||
const lineLimit = this.configurationService.getValue<number>(TextOutputLineLimit) ?? 30;
|
||||
truncatedArrayOfString(notebookUri, output.cellViewModel, Math.max(lineLimit, 6), contentNode, [str], linkDetector, this.openerService, this.themeService);
|
||||
container.appendChild(contentNode);
|
||||
|
||||
return { type: RenderOutputType.Mainframe, supportAppend: true };
|
||||
|
|
|
@ -20,7 +20,6 @@ import { URI } from 'vs/base/common/uri';
|
|||
import { IGenericCellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
|
||||
const SIZE_LIMIT = 65535;
|
||||
const LINES_LIMIT = 500;
|
||||
|
||||
function generateViewMoreElement(notebookUri: URI, cellViewModel: IGenericCellViewModel, outputs: string[], openerService: IOpenerService) {
|
||||
const md: IMarkdownString = {
|
||||
|
@ -46,7 +45,7 @@ function generateViewMoreElement(notebookUri: URI, cellViewModel: IGenericCellVi
|
|||
return element;
|
||||
}
|
||||
|
||||
export function truncatedArrayOfString(notebookUri: URI, cellViewModel: IGenericCellViewModel, container: HTMLElement, outputs: string[], linkDetector: LinkDetector, openerService: IOpenerService, themeService: IThemeService) {
|
||||
export function truncatedArrayOfString(notebookUri: URI, cellViewModel: IGenericCellViewModel, linesLimit: number, container: HTMLElement, outputs: string[], linkDetector: LinkDetector, openerService: IOpenerService, themeService: IThemeService) {
|
||||
const fullLen = outputs.reduce((p, c) => {
|
||||
return p + c.length;
|
||||
}, 0);
|
||||
|
@ -60,7 +59,7 @@ export function truncatedArrayOfString(notebookUri: URI, cellViewModel: IGeneric
|
|||
const factory = bufferBuilder.finish();
|
||||
buffer = factory.create(DefaultEndOfLine.LF).textBuffer;
|
||||
const sizeBufferLimitPosition = buffer.getPositionAt(SIZE_LIMIT);
|
||||
if (sizeBufferLimitPosition.lineNumber < LINES_LIMIT) {
|
||||
if (sizeBufferLimitPosition.lineNumber < linesLimit) {
|
||||
const truncatedText = buffer.getValueInRange(new Range(1, 1, sizeBufferLimitPosition.lineNumber, sizeBufferLimitPosition.column), EndOfLinePreference.TextDefined);
|
||||
container.appendChild(handleANSIOutput(truncatedText, linkDetector, themeService, undefined));
|
||||
// view more ...
|
||||
|
@ -76,7 +75,7 @@ export function truncatedArrayOfString(notebookUri: URI, cellViewModel: IGeneric
|
|||
buffer = factory.create(DefaultEndOfLine.LF).textBuffer;
|
||||
}
|
||||
|
||||
if (buffer.getLineCount() < LINES_LIMIT) {
|
||||
if (buffer.getLineCount() < linesLimit) {
|
||||
const lineCount = buffer.getLineCount();
|
||||
const fullRange = new Range(1, 1, lineCount, Math.max(1, buffer.getLineLastNonWhitespaceColumn(lineCount)));
|
||||
container.appendChild(handleANSIOutput(buffer.getValueInRange(fullRange, EndOfLinePreference.TextDefined), linkDetector, themeService, undefined));
|
||||
|
@ -85,7 +84,7 @@ export function truncatedArrayOfString(notebookUri: URI, cellViewModel: IGeneric
|
|||
|
||||
const pre = DOM.$('pre');
|
||||
container.appendChild(pre);
|
||||
pre.appendChild(handleANSIOutput(buffer.getValueInRange(new Range(1, 1, LINES_LIMIT - 5, buffer.getLineLastNonWhitespaceColumn(LINES_LIMIT - 5)), EndOfLinePreference.TextDefined), linkDetector, themeService, undefined));
|
||||
pre.appendChild(handleANSIOutput(buffer.getValueInRange(new Range(1, 1, linesLimit - 5, buffer.getLineLastNonWhitespaceColumn(linesLimit - 5)), EndOfLinePreference.TextDefined), linkDetector, themeService, undefined));
|
||||
|
||||
// view more ...
|
||||
container.appendChild(generateViewMoreElement(notebookUri, cellViewModel, outputs, openerService));
|
||||
|
|
|
@ -850,6 +850,7 @@ export const DragAndDropEnabled = 'notebook.dragAndDropEnabled';
|
|||
export const NotebookCellEditorOptionsCustomizations = 'notebook.editorOptionsCustomizations';
|
||||
export const ConsolidatedRunButton = 'notebook.consolidatedRunButton';
|
||||
export const OpenGettingStarted = 'notebook.experimental.openGettingStarted';
|
||||
export const TextOutputLineLimit = 'notebook.output.textLineLimit';
|
||||
|
||||
export const enum CellStatusbarAlignment {
|
||||
Left = 1,
|
||||
|
|
Loading…
Reference in a new issue