Allow for auto-resizable editor component (#2818)

This commit is contained in:
Chris LaFreniere
2018-10-11 16:18:58 -07:00
committed by GitHub
parent 1d8132bcaa
commit 5c77e752f6
4 changed files with 47 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ import { EditorOptions } from 'vs/workbench/common/editor';
import { StandaloneCodeEditor } from 'vs/editor/standalone/browser/standaloneCodeEditor';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { Configuration } from 'vs/editor/browser/config/configuration';
/**
* Extension of TextResourceEditor that is always readonly rather than only with non UntitledInputs
@@ -31,6 +33,7 @@ export class QueryTextEditor extends BaseTextEditor {
public static ID = 'modelview.editors.textEditor';
private _dimension: DOM.Dimension;
private _config: editorCommon.IConfiguration;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IInstantiationService instantiationService: IInstantiationService,
@@ -98,7 +101,21 @@ export class QueryTextEditor extends BaseTextEditor {
public setHeight(height: number) {
if (this._dimension) {
this._dimension.height = height;
this.layout();
this.layout(this._dimension);
}
}
public get scrollHeight(): number {
let editorWidget = this.getControl() as ICodeEditor;
return editorWidget.getScrollHeight();
}
public setHeightToScrollHeight(): void {
let editorWidget = this.getControl() as ICodeEditor;
if (!this._config) {
this._config = new Configuration(undefined, editorWidget.getDomNode());
}
let editorHeightUsingLines = this._config.editor.lineHeight * editorWidget.getModel().getLineCount();
this.setHeight(editorHeightUsingLines);
}
}