mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 01:25:38 -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';
|
||||
private _dimension: DOM.Dimension;
|
||||
private _config: editorCommon.IConfiguration;
|
||||
private _minHeight: number = 0;
|
||||
private _maxHeight: number = 4000;
|
||||
private _selected: boolean;
|
||||
private _hideLineNumbers: boolean;
|
||||
private _editorWorkspaceConfig;
|
||||
private _scrollbarHeight: number;
|
||||
private _lineHeight: number;
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@@ -132,9 +132,9 @@ export class QueryTextEditor extends BaseTextEditor {
|
||||
|
||||
public setHeightToScrollHeight(configChanged?: boolean): void {
|
||||
let editorWidget = this.getControl() as ICodeEditor;
|
||||
this._config = new Configuration(true, undefined, editorWidget.getDomNode(), this.accessibilityService);
|
||||
let layoutInfo = editorWidget.getLayoutInfo();
|
||||
if (!this._scrollbarHeight) {
|
||||
this._scrollbarHeight = this._config.editor.viewInfo.scrollbar.horizontalScrollbarSize;
|
||||
this._scrollbarHeight = layoutInfo.horizontalScrollbarHeight;
|
||||
}
|
||||
let editorWidgetModel = editorWidget.getModel();
|
||||
if (!editorWidgetModel) {
|
||||
@@ -151,26 +151,27 @@ export class QueryTextEditor extends BaseTextEditor {
|
||||
let shouldAddHorizontalScrollbarHeight = false;
|
||||
if (!this._editorWorkspaceConfig || configChanged) {
|
||||
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;
|
||||
if (wordWrapEnabled) {
|
||||
for (let line = 1; line <= lineCount; line++) {
|
||||
// 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
|
||||
numberWrappedLines += Math.ceil(editorWidgetModel.getLineMaxColumn(line) / this._config.editor.layoutInfo.viewportColumn) - 1;
|
||||
numberWrappedLines += Math.ceil(editorWidgetModel.getLineMaxColumn(line) / layoutInfo.viewportColumn) - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let line = 1; line <= lineCount; line++) {
|
||||
// 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;
|
||||
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);
|
||||
editorHeightUsingMinHeight = shouldAddHorizontalScrollbarHeight ? editorHeightUsingMinHeight + this._scrollbarHeight : editorHeightUsingMinHeight;
|
||||
this.setHeight(editorHeightUsingMinHeight);
|
||||
|
||||
@@ -226,7 +226,7 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
|
||||
setTimeout(() => this._layoutEmitter.fire(), 250);
|
||||
}));
|
||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('editor.wordWrap')) {
|
||||
if (e.affectsConfiguration('editor.wordWrap') || e.affectsConfiguration('editor.fontSize')) {
|
||||
this._editor.setHeightToScrollHeight(true);
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user