added setting for notebook output line height

pull/147321/head
aamunger 2022-04-11 12:44:15 -07:00
parent 675b8c3da0
commit 9a87fe7eaf
No known key found for this signature in database
GPG Key ID: F2CA0C6303FC6B74
6 changed files with 31 additions and 5 deletions

View File

@ -174,7 +174,7 @@ export const activate: ActivationFunction<void> = (ctx) => {
.output-plaintext,
.output-stream,
.traceback {
line-height: 22px;
line-height: var(--notebook-cell-output-line-height);
font-family: var(--notebook-cell-output-font-family);
white-space: pre-wrap;
word-wrap: break-word;
@ -185,6 +185,9 @@ export const activate: ActivationFunction<void> = (ctx) => {
-ms-user-select: text;
cursor: auto;
}
span.output-stream {
display: inline-block;
}
.output-plaintext .code-bold,
.output-stream .code-bold,
.traceback .code-bold {

View File

@ -892,5 +892,11 @@ configurationRegistry.registerConfiguration({
enum: ['always', 'never', 'fromEditor'],
default: 'fromEditor'
},
[NotebookSetting.outputLineHeight]: {
markdownDescription: nls.localize('notebook.outputLineHeight', "line height of the output text"),
type: 'number',
default: 22,
tags: ['notebookLayout']
},
}
});

View File

@ -397,7 +397,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
this._updateForNotebookConfiguration();
}
if (e.compactView || e.focusIndicator || e.insertToolbarPosition || e.cellToolbarLocation || e.dragAndDropEnabled || e.fontSize || e.markupFontSize || e.insertToolbarAlignment) {
if (e.compactView || e.focusIndicator || e.insertToolbarPosition || e.cellToolbarLocation || e.dragAndDropEnabled || e.fontSize || e.markupFontSize || e.insertToolbarAlignment || e.outputLineHeight) {
this._styleElement?.remove();
this._createLayoutStyles();
this._webview?.updateOptions({

View File

@ -81,6 +81,7 @@ export interface INotebookDelegateForWebview {
interface BacklayerWebviewOptions {
readonly outputNodePadding: number;
readonly outputNodeLeftPadding: number;
readonly outputLineHeight: number;
readonly previewNodePadding: number;
readonly markdownLeftMargin: number;
readonly leftMargin: number;
@ -205,6 +206,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Disposable {
'notebook-markdown-min-height': `${this.options.previewNodePadding * 2}px`,
'notebook-markup-font-size': typeof this.options.markupFontSize === 'number' && this.options.markupFontSize > 0 ? `${this.options.markupFontSize}px` : `calc(${this.options.fontSize}px * 1.2)`,
'notebook-cell-output-font-size': `${this.options.fontSize}px`,
'notebook-cell-output-line-height': `${this.options.outputLineHeight}px`,
'notebook-cell-output-font-family': this.options.fontFamily,
'notebook-cell-markup-empty-content': nls.localize('notebook.emptyMarkdownPlaceholder', "Empty markdown cell, double click or press enter to edit."),
'notebook-cell-renderer-not-found-error': nls.localize({

View File

@ -913,7 +913,8 @@ export const NotebookSetting = {
textOutputLineLimit: 'notebook.output.textLineLimit',
globalToolbarShowLabel: 'notebook.globalToolbarShowLabel',
markupFontSize: 'notebook.markup.fontSize',
interactiveWindowCollapseCodeCells: 'interactiveWindow.collapseCellInputCode'
interactiveWindowCollapseCodeCells: 'interactiveWindow.collapseCellInputCode',
outputLineHeight: 'notebook.outputLineHeight'
} as const;
export const enum CellStatusbarAlignment {

View File

@ -62,6 +62,7 @@ export interface NotebookLayoutConfiguration {
showFoldingControls: 'always' | 'mouseover';
dragAndDropEnabled: boolean;
fontSize: number;
outputLineHeight: number;
markupFontSize: number;
focusIndicatorLeftMargin: number;
editorOptionsCustomizations: any | undefined;
@ -87,6 +88,7 @@ export interface NotebookOptionsChangeEvent {
readonly markupFontSize?: boolean;
readonly editorOptionsCustomizations?: boolean;
readonly interactiveWindowCollapseCodeCells?: boolean;
readonly outputLineHeight?: boolean;
}
const defaultConfigConstants = Object.freeze({
@ -137,6 +139,7 @@ export class NotebookOptions extends Disposable {
const markupFontSize = this.configurationService.getValue<number>(NotebookSetting.markupFontSize);
const editorOptionsCustomizations = this.configurationService.getValue(NotebookSetting.cellEditorOptionsCustomizations);
const interactiveWindowCollapseCodeCells: InteractiveWindowCollapseCodeCells = this.configurationService.getValue(NotebookSetting.interactiveWindowCollapseCodeCells);
const outputLineHeight = this.configurationService.getValue<number>(NotebookSetting.outputLineHeight);
this._layoutConfiguration = {
...(compactView ? compactConfigConstants : defaultConfigConstants),
@ -166,6 +169,7 @@ export class NotebookOptions extends Disposable {
insertToolbarAlignment,
showFoldingControls,
fontSize,
outputLineHeight,
markupFontSize,
editorOptionsCustomizations,
focusIndicatorGap: 3,
@ -202,6 +206,7 @@ export class NotebookOptions extends Disposable {
const markupFontSize = e.affectsConfiguration(NotebookSetting.markupFontSize);
const editorOptionsCustomizations = e.affectsConfiguration(NotebookSetting.cellEditorOptionsCustomizations);
const interactiveWindowCollapseCodeCells = e.affectsConfiguration(NotebookSetting.interactiveWindowCollapseCodeCells);
const outputLineHeight = e.affectsConfiguration(NotebookSetting.outputLineHeight);
if (
!cellStatusBarVisibility
@ -219,7 +224,8 @@ export class NotebookOptions extends Disposable {
&& !fontSize
&& !markupFontSize
&& !editorOptionsCustomizations
&& !interactiveWindowCollapseCodeCells) {
&& !interactiveWindowCollapseCodeCells
&& !outputLineHeight) {
return;
}
@ -293,8 +299,13 @@ export class NotebookOptions extends Disposable {
configuration.interactiveWindowCollapseCodeCells = this.configurationService.getValue(NotebookSetting.interactiveWindowCollapseCodeCells);
}
if (outputLineHeight) {
configuration.outputLineHeight = this.configurationService.getValue<number>(NotebookSetting.outputLineHeight);
}
this._layoutConfiguration = Object.freeze(configuration);
// add new configuration to the event?
// trigger event
this._onDidChangeOptions.fire({
cellStatusBarVisibility,
@ -312,7 +323,8 @@ export class NotebookOptions extends Disposable {
fontSize,
markupFontSize,
editorOptionsCustomizations,
interactiveWindowCollapseCodeCells
interactiveWindowCollapseCodeCells,
outputLineHeight
});
}
@ -503,6 +515,7 @@ export class NotebookOptions extends Disposable {
dragAndDropEnabled: this._layoutConfiguration.dragAndDropEnabled,
fontSize: this._layoutConfiguration.fontSize,
markupFontSize: this._layoutConfiguration.markupFontSize,
outputLineHeight: this._layoutConfiguration.outputLineHeight,
};
}
@ -518,6 +531,7 @@ export class NotebookOptions extends Disposable {
dragAndDropEnabled: false,
fontSize: this._layoutConfiguration.fontSize,
markupFontSize: this._layoutConfiguration.markupFontSize,
outputLineHeight: this._layoutConfiguration.outputLineHeight,
};
}