Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Rieken <johannes.rieken@gmail.com>2022-05-04 09:42:43 +0300
committerGitHub <noreply@github.com>2022-05-04 09:42:43 +0300
commit12c535e2bd7f261a94a5aa1267fa940055706f8c (patch)
tree63456f645a98a08889b97032c5312237f95f5d4d /src/vs/workbench/contrib/notebook/common/notebookOptions.ts
parent4ef3ed3ce8d7ab1857d41454449d32f946d3ac8c (diff)
parent9556854c8fc9199b4ffd06b4e17140e8fb78d0f4 (diff)
Merge branch 'main' into joh/cellUri
Diffstat (limited to 'src/vs/workbench/contrib/notebook/common/notebookOptions.ts')
-rw-r--r--src/vs/workbench/contrib/notebook/common/notebookOptions.ts70
1 files changed, 68 insertions, 2 deletions
diff --git a/src/vs/workbench/contrib/notebook/common/notebookOptions.ts b/src/vs/workbench/contrib/notebook/common/notebookOptions.ts
index 9564a563def..426871f84fa 100644
--- a/src/vs/workbench/contrib/notebook/common/notebookOptions.ts
+++ b/src/vs/workbench/contrib/notebook/common/notebookOptions.ts
@@ -62,6 +62,9 @@ export interface NotebookLayoutConfiguration {
showFoldingControls: 'always' | 'mouseover';
dragAndDropEnabled: boolean;
fontSize: number;
+ outputFontSize: number;
+ outputFontFamily: string;
+ outputLineHeight: number;
markupFontSize: number;
focusIndicatorLeftMargin: number;
editorOptionsCustomizations: any | undefined;
@@ -84,9 +87,13 @@ export interface NotebookOptionsChangeEvent {
readonly consolidatedRunButton?: boolean;
readonly dragAndDropEnabled?: boolean;
readonly fontSize?: boolean;
+ readonly outputFontSize?: boolean;
readonly markupFontSize?: boolean;
+ readonly fontFamily?: boolean;
+ readonly outputFontFamily?: boolean;
readonly editorOptionsCustomizations?: boolean;
readonly interactiveWindowCollapseCodeCells?: boolean;
+ readonly outputLineHeight?: boolean;
}
const defaultConfigConstants = Object.freeze({
@@ -134,9 +141,12 @@ export class NotebookOptions extends Disposable {
const showFoldingControls = this._computeShowFoldingControlsOption();
// const { bottomToolbarGap, bottomToolbarHeight } = this._computeBottomToolbarDimensions(compactView, insertToolbarPosition, insertToolbarAlignment);
const fontSize = this.configurationService.getValue<number>('editor.fontSize');
+ const outputFontSize = this.configurationService.getValue<number>(NotebookSetting.outputFontSize);
+ const outputFontFamily = this.configurationService.getValue<string>(NotebookSetting.outputFontFamily);
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._computeOutputLineHeight();
this._layoutConfiguration = {
...(compactView ? compactConfigConstants : defaultConfigConstants),
@@ -166,6 +176,9 @@ export class NotebookOptions extends Disposable {
insertToolbarAlignment,
showFoldingControls,
fontSize,
+ outputFontSize,
+ outputFontFamily,
+ outputLineHeight,
markupFontSize,
editorOptionsCustomizations,
focusIndicatorGap: 3,
@@ -185,6 +198,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);
@@ -199,9 +235,13 @@ export class NotebookOptions extends Disposable {
const showFoldingControls = e.affectsConfiguration(NotebookSetting.showFoldingControls);
const dragAndDropEnabled = e.affectsConfiguration(NotebookSetting.dragAndDropEnabled);
const fontSize = e.affectsConfiguration('editor.fontSize');
+ const outputFontSize = e.affectsConfiguration(NotebookSetting.outputFontSize);
const markupFontSize = e.affectsConfiguration(NotebookSetting.markupFontSize);
+ const fontFamily = e.affectsConfiguration('editor.fontFamily');
+ const outputFontFamily = e.affectsConfiguration(NotebookSetting.outputFontFamily);
const editorOptionsCustomizations = e.affectsConfiguration(NotebookSetting.cellEditorOptionsCustomizations);
const interactiveWindowCollapseCodeCells = e.affectsConfiguration(NotebookSetting.interactiveWindowCollapseCodeCells);
+ const outputLineHeight = e.affectsConfiguration(NotebookSetting.outputLineHeight);
if (
!cellStatusBarVisibility
@@ -217,9 +257,13 @@ export class NotebookOptions extends Disposable {
&& !showFoldingControls
&& !dragAndDropEnabled
&& !fontSize
+ && !outputFontSize
&& !markupFontSize
+ && !fontFamily
+ && !outputFontFamily
&& !editorOptionsCustomizations
- && !interactiveWindowCollapseCodeCells) {
+ && !interactiveWindowCollapseCodeCells
+ && !outputLineHeight) {
return;
}
@@ -281,10 +325,18 @@ export class NotebookOptions extends Disposable {
configuration.fontSize = this.configurationService.getValue<number>('editor.fontSize');
}
+ if (outputFontSize) {
+ configuration.outputFontSize = this.configurationService.getValue<number>(NotebookSetting.outputFontSize) ?? configuration.fontSize;
+ }
+
if (markupFontSize) {
configuration.markupFontSize = this.configurationService.getValue<number>(NotebookSetting.markupFontSize);
}
+ if (outputFontFamily) {
+ configuration.outputFontFamily = this.configurationService.getValue<string>(NotebookSetting.outputFontFamily);
+ }
+
if (editorOptionsCustomizations) {
configuration.editorOptionsCustomizations = this.configurationService.getValue(NotebookSetting.cellEditorOptionsCustomizations);
}
@@ -293,6 +345,10 @@ export class NotebookOptions extends Disposable {
configuration.interactiveWindowCollapseCodeCells = this.configurationService.getValue(NotebookSetting.interactiveWindowCollapseCodeCells);
}
+ if (outputLineHeight || fontSize || outputFontSize) {
+ configuration.outputLineHeight = this._computeOutputLineHeight();
+ }
+
this._layoutConfiguration = Object.freeze(configuration);
// trigger event
@@ -310,9 +366,13 @@ export class NotebookOptions extends Disposable {
consolidatedRunButton,
dragAndDropEnabled,
fontSize,
+ outputFontSize,
markupFontSize,
+ fontFamily,
+ outputFontFamily,
editorOptionsCustomizations,
- interactiveWindowCollapseCodeCells
+ interactiveWindowCollapseCodeCells,
+ outputLineHeight
});
}
@@ -502,7 +562,10 @@ export class NotebookOptions extends Disposable {
runGutter: this._layoutConfiguration.cellRunGutter,
dragAndDropEnabled: this._layoutConfiguration.dragAndDropEnabled,
fontSize: this._layoutConfiguration.fontSize,
+ outputFontSize: this._layoutConfiguration.outputFontSize,
+ outputFontFamily: this._layoutConfiguration.outputFontFamily,
markupFontSize: this._layoutConfiguration.markupFontSize,
+ outputLineHeight: this._layoutConfiguration.outputLineHeight,
};
}
@@ -517,7 +580,10 @@ export class NotebookOptions extends Disposable {
runGutter: 0,
dragAndDropEnabled: false,
fontSize: this._layoutConfiguration.fontSize,
+ outputFontSize: this._layoutConfiguration.outputFontSize,
+ outputFontFamily: this._layoutConfiguration.outputFontFamily,
markupFontSize: this._layoutConfiguration.markupFontSize,
+ outputLineHeight: this._layoutConfiguration.outputLineHeight,
};
}