mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Support non-default font sizes in notebooks (#6222)
* Support non-default font sizes notebooks * pr comments
This commit is contained in:
@@ -35,13 +35,13 @@ export class QueryTextEditor extends BaseTextEditor {
|
|||||||
|
|
||||||
public static ID = 'modelview.editors.textEditor';
|
public static ID = 'modelview.editors.textEditor';
|
||||||
private _dimension: DOM.Dimension;
|
private _dimension: DOM.Dimension;
|
||||||
private _config: editorCommon.IConfiguration;
|
|
||||||
private _minHeight: number = 0;
|
private _minHeight: number = 0;
|
||||||
private _maxHeight: number = 4000;
|
private _maxHeight: number = 4000;
|
||||||
private _selected: boolean;
|
private _selected: boolean;
|
||||||
private _hideLineNumbers: boolean;
|
private _hideLineNumbers: boolean;
|
||||||
private _editorWorkspaceConfig;
|
private _editorWorkspaceConfig;
|
||||||
private _scrollbarHeight: number;
|
private _scrollbarHeight: number;
|
||||||
|
private _lineHeight: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ITelemetryService telemetryService: ITelemetryService,
|
@ITelemetryService telemetryService: ITelemetryService,
|
||||||
@@ -132,9 +132,9 @@ export class QueryTextEditor extends BaseTextEditor {
|
|||||||
|
|
||||||
public setHeightToScrollHeight(configChanged?: boolean): void {
|
public setHeightToScrollHeight(configChanged?: boolean): void {
|
||||||
let editorWidget = this.getControl() as ICodeEditor;
|
let editorWidget = this.getControl() as ICodeEditor;
|
||||||
this._config = new Configuration(true, undefined, editorWidget.getDomNode(), this.accessibilityService);
|
let layoutInfo = editorWidget.getLayoutInfo();
|
||||||
if (!this._scrollbarHeight) {
|
if (!this._scrollbarHeight) {
|
||||||
this._scrollbarHeight = this._config.editor.viewInfo.scrollbar.horizontalScrollbarSize;
|
this._scrollbarHeight = layoutInfo.horizontalScrollbarHeight;
|
||||||
}
|
}
|
||||||
let editorWidgetModel = editorWidget.getModel();
|
let editorWidgetModel = editorWidget.getModel();
|
||||||
if (!editorWidgetModel) {
|
if (!editorWidgetModel) {
|
||||||
@@ -151,26 +151,27 @@ export class QueryTextEditor extends BaseTextEditor {
|
|||||||
let shouldAddHorizontalScrollbarHeight = false;
|
let shouldAddHorizontalScrollbarHeight = false;
|
||||||
if (!this._editorWorkspaceConfig || configChanged) {
|
if (!this._editorWorkspaceConfig || configChanged) {
|
||||||
this._editorWorkspaceConfig = this.workspaceConfigurationService.getValue('editor');
|
this._editorWorkspaceConfig = this.workspaceConfigurationService.getValue('editor');
|
||||||
|
this._lineHeight = editorWidget.getConfiguration().lineHeight;
|
||||||
}
|
}
|
||||||
let wordWrapEnabled: boolean = this._editorWorkspaceConfig && this._editorWorkspaceConfig['wordWrap'] && this._editorWorkspaceConfig['wordWrap'] === 'on' ? true : false;
|
let wordWrapEnabled: boolean = this._editorWorkspaceConfig && this._editorWorkspaceConfig['wordWrap'] && this._editorWorkspaceConfig['wordWrap'] === 'on' ? true : false;
|
||||||
if (wordWrapEnabled) {
|
if (wordWrapEnabled) {
|
||||||
for (let line = 1; line <= lineCount; line++) {
|
for (let line = 1; line <= lineCount; line++) {
|
||||||
// 4 columns is equivalent to the viewport column width and the edge of the editor
|
// 4 columns is equivalent to the viewport column width and the edge of the editor
|
||||||
if (editorWidgetModel.getLineMaxColumn(line) >= this._config.editor.layoutInfo.viewportColumn + 4) {
|
if (editorWidgetModel.getLineMaxColumn(line) >= layoutInfo.viewportColumn + 4) {
|
||||||
// Subtract 1 because the first line should not count as a wrapped line
|
// Subtract 1 because the first line should not count as a wrapped line
|
||||||
numberWrappedLines += Math.ceil(editorWidgetModel.getLineMaxColumn(line) / this._config.editor.layoutInfo.viewportColumn) - 1;
|
numberWrappedLines += Math.ceil(editorWidgetModel.getLineMaxColumn(line) / layoutInfo.viewportColumn) - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let line = 1; line <= lineCount; line++) {
|
for (let line = 1; line <= lineCount; line++) {
|
||||||
// The horizontal scrollbar always appears 1 column past the viewport column when word wrap is disabled
|
// The horizontal scrollbar always appears 1 column past the viewport column when word wrap is disabled
|
||||||
if (editorWidgetModel.getLineMaxColumn(line) >= this._config.editor.layoutInfo.viewportColumn + 1) {
|
if (editorWidgetModel.getLineMaxColumn(line) >= layoutInfo.viewportColumn + 1) {
|
||||||
shouldAddHorizontalScrollbarHeight = true;
|
shouldAddHorizontalScrollbarHeight = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let editorHeightUsingLines = this._config.editor.lineHeight * (lineCount + numberWrappedLines);
|
let editorHeightUsingLines = this._lineHeight * (lineCount + numberWrappedLines);
|
||||||
let editorHeightUsingMinHeight = Math.max(Math.min(editorHeightUsingLines, this._maxHeight), this._minHeight);
|
let editorHeightUsingMinHeight = Math.max(Math.min(editorHeightUsingLines, this._maxHeight), this._minHeight);
|
||||||
editorHeightUsingMinHeight = shouldAddHorizontalScrollbarHeight ? editorHeightUsingMinHeight + this._scrollbarHeight : editorHeightUsingMinHeight;
|
editorHeightUsingMinHeight = shouldAddHorizontalScrollbarHeight ? editorHeightUsingMinHeight + this._scrollbarHeight : editorHeightUsingMinHeight;
|
||||||
this.setHeight(editorHeightUsingMinHeight);
|
this.setHeight(editorHeightUsingMinHeight);
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
|
|||||||
setTimeout(() => this._layoutEmitter.fire(), 250);
|
setTimeout(() => this._layoutEmitter.fire(), 250);
|
||||||
}));
|
}));
|
||||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
||||||
if (e.affectsConfiguration('editor.wordWrap')) {
|
if (e.affectsConfiguration('editor.wordWrap') || e.affectsConfiguration('editor.fontSize')) {
|
||||||
this._editor.setHeightToScrollHeight(true);
|
this._editor.setHeightToScrollHeight(true);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user