diff options
author | aamunger <aamunger@microsoft.com> | 2022-04-12 22:46:09 +0300 |
---|---|---|
committer | aamunger <aamunger@microsoft.com> | 2022-04-13 19:12:35 +0300 |
commit | fe38a7b3bd41d5f7fe0e29579308f625d68ea170 (patch) | |
tree | 97d568f5a1b1df6cb0c392e289886a5ee3aedd2b /src/vs | |
parent | 51ab78f535d8537e031e1ae77cac678ae22b0249 (diff) |
line height as ratio when < 8
Diffstat (limited to 'src/vs')
4 files changed, 32 insertions, 20 deletions
diff --git a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts index 17c7255ad50..b96059530d4 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -893,19 +893,19 @@ configurationRegistry.registerConfiguration({ default: 'fromEditor' }, [NotebookSetting.outputLineHeight]: { - markdownDescription: nls.localize('notebook.outputLineHeight', "Line height of the output text"), + markdownDescription: nls.localize('notebook.outputLineHeight', "Line height of the output text for notebook cells.\n - Values between 0 and 8 will be used as a multiplier with the font size.\n - Values greater than or equal to 8 will be used as effective values."), type: 'number', default: 22, tags: ['notebookLayout'] }, [NotebookSetting.outputFontSize]: { - markdownDescription: nls.localize('notebook.outputFontSize', "Font size for plain text outputs. When set to 0 `#editor.fontSize#` is used."), + markdownDescription: nls.localize('notebook.outputFontSize', "Font size for the output text for notebook cells. When set to 0 `#editor.fontSize#` is used."), type: 'number', default: 0, tags: ['notebookLayout'] }, [NotebookSetting.outputFontFamily]: { - markdownDescription: nls.localize('notebook.outputFontFamily', "The font family for plain text output of notebook cells. When set to empty, the `#editor.fontFamily#` is used."), + markdownDescription: nls.localize('notebook.outputFontFamily', "The font family for the output text for notebook cells. When set to empty, the `#editor.fontFamily#` is used."), type: 'string', tags: ['notebookLayout'] }, diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index 15e56226ccd..93bcb157f61 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -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.outputFontSize || e.fontFamily || e.outputFontFamily || e.markupFontSize || e.insertToolbarAlignment || e.outputLineHeight) { + if (e.compactView || e.focusIndicator || e.insertToolbarPosition || e.cellToolbarLocation || e.dragAndDropEnabled || e.fontSize || e.outputFontSize || e.markupFontSize || e.insertToolbarAlignment || e.outputLineHeight) { this._styleElement?.remove(); this._createLayoutStyles(); this._webview?.updateOptions({ diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index 121ac0689da..5f70d558da1 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -916,7 +916,7 @@ export const NotebookSetting = { interactiveWindowCollapseCodeCells: 'interactiveWindow.collapseCellInputCode', outputLineHeight: 'notebook.outputLineHeight', outputFontSize: 'notebook.outputFontSize', - outputFontFamily: 'notebook.fontFamily' + outputFontFamily: 'notebook.outputFontFamily' } as const; export const enum CellStatusbarAlignment { diff --git a/src/vs/workbench/contrib/notebook/common/notebookOptions.ts b/src/vs/workbench/contrib/notebook/common/notebookOptions.ts index b7c9b89a926..2964a52df79 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookOptions.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookOptions.ts @@ -88,8 +88,6 @@ export interface NotebookOptionsChangeEvent { readonly dragAndDropEnabled?: boolean; readonly fontSize?: boolean; readonly outputFontSize?: boolean; - readonly fontFamily?: boolean; - readonly outputFontFamily?: boolean; readonly markupFontSize?: boolean; readonly editorOptionsCustomizations?: boolean; readonly interactiveWindowCollapseCodeCells?: boolean; @@ -146,7 +144,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); + const outputLineHeight = this._computeOutputLineHeight(); this._layoutConfiguration = { ...(compactView ? compactConfigConstants : defaultConfigConstants), @@ -198,6 +196,29 @@ export class NotebookOptions extends Disposable { })); } + private _computeOutputLineHeight(): number { + const minimumLineHeight = 8; + let lineHeight = this.configurationService.getValue<number>(NotebookSetting.outputLineHeight); + + if (lineHeight < minimumLineHeight) { + // Values too small to be line heights in pixels are in ems. + let fontSize = this.configurationService.getValue<number>(NotebookSetting.outputFontSize); + if (fontSize === 0) { + fontSize = this.configurationService.getValue<number>('editor.fontSize'); + } + + lineHeight = lineHeight * fontSize; + } + + // Enforce integer, minimum constraints + lineHeight = Math.round(lineHeight); + if (lineHeight < minimumLineHeight) { + lineHeight = minimumLineHeight; + } + + return lineHeight; + } + private _updateConfiguration(e: IConfigurationChangeEvent) { const cellStatusBarVisibility = e.affectsConfiguration(NotebookSetting.showCellStatusBar); const cellToolbarLocation = e.affectsConfiguration(NotebookSetting.cellToolbarLocation); @@ -213,8 +234,6 @@ export class NotebookOptions extends Disposable { const dragAndDropEnabled = e.affectsConfiguration(NotebookSetting.dragAndDropEnabled); const fontSize = e.affectsConfiguration('editor.fontSize'); const outputFontSize = e.affectsConfiguration(NotebookSetting.outputFontSize); - const fontFamily = e.affectsConfiguration('editor.fontFamily'); - const outputFontFamily = e.affectsConfiguration(NotebookSetting.outputFontFamily); const markupFontSize = e.affectsConfiguration(NotebookSetting.markupFontSize); const editorOptionsCustomizations = e.affectsConfiguration(NotebookSetting.cellEditorOptionsCustomizations); const interactiveWindowCollapseCodeCells = e.affectsConfiguration(NotebookSetting.interactiveWindowCollapseCodeCells); @@ -236,8 +255,6 @@ export class NotebookOptions extends Disposable { && !dragAndDropEnabled && !fontSize && !outputFontSize - && !fontFamily - && !outputFontFamily && !markupFontSize && !editorOptionsCustomizations && !interactiveWindowCollapseCodeCells @@ -304,11 +321,7 @@ export class NotebookOptions extends Disposable { } if (outputFontSize) { - configuration.outputFontSize = this.configurationService.getValue<number>(NotebookSetting.outputFontSize); - } - - if (outputFontFamily) { - configuration.outputFontFamily = this.configurationService.getValue<string>(NotebookSetting.outputFontFamily); + configuration.outputFontSize = this.configurationService.getValue<number>(NotebookSetting.outputFontSize) ?? configuration.fontSize; } if (markupFontSize) { @@ -323,8 +336,8 @@ export class NotebookOptions extends Disposable { configuration.interactiveWindowCollapseCodeCells = this.configurationService.getValue(NotebookSetting.interactiveWindowCollapseCodeCells); } - if (outputLineHeight) { - configuration.outputLineHeight = this.configurationService.getValue<number>(NotebookSetting.outputLineHeight); + if (outputLineHeight || fontSize || outputFontSize) { + configuration.outputLineHeight = this._computeOutputLineHeight(); } this._layoutConfiguration = Object.freeze(configuration); @@ -346,7 +359,6 @@ export class NotebookOptions extends Disposable { dragAndDropEnabled, fontSize, outputFontSize, - outputFontFamily, markupFontSize, editorOptionsCustomizations, interactiveWindowCollapseCodeCells, |