#4132 fix for disolayError (#4133)

This commit is contained in:
Raj
2019-02-22 16:00:59 -08:00
committed by Kevin Cunnane
parent 1e915aad20
commit da3fbd386d

View File

@@ -31,6 +31,7 @@ import { Emitter, debounceEvent } from 'vs/base/common/event';
import { CellTypes } from 'sql/parts/notebook/models/contracts'; import { CellTypes } from 'sql/parts/notebook/models/contracts';
import { OVERRIDE_EDITOR_THEMING_SETTING } from 'sql/workbench/services/notebook/common/notebookService'; import { OVERRIDE_EDITOR_THEMING_SETTING } from 'sql/workbench/services/notebook/common/notebookService';
import * as notebookUtils from 'sql/parts/notebook/notebookUtils'; import * as notebookUtils from 'sql/parts/notebook/notebookUtils';
import { UntitledEditorModel } from 'vs/workbench/common/editor/untitledEditorModel';
export const CODE_SELECTOR: string = 'code-component'; export const CODE_SELECTOR: string = 'code-component';
const MARKDOWN_CLASS = 'markdown'; const MARKDOWN_CLASS = 'markdown';
@@ -153,7 +154,7 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
return this._activeCellId; return this._activeCellId;
} }
private createEditor(): void { private async createEditor(): Promise<void> {
let instantiationService = this._instantiationService.createChild(new ServiceCollection([IProgressService, new SimpleProgressService()])); let instantiationService = this._instantiationService.createChild(new ServiceCollection([IProgressService, new SimpleProgressService()]));
this._editor = instantiationService.createInstance(QueryTextEditor); this._editor = instantiationService.createInstance(QueryTextEditor);
this._editor.create(this.codeElement.nativeElement); this._editor.create(this.codeElement.nativeElement);
@@ -162,12 +163,13 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
this._editor.setMaximumHeight(this._maximumHeight); this._editor.setMaximumHeight(this._maximumHeight);
let uri = this.cellModel.cellUri; let uri = this.cellModel.cellUri;
this._editorInput = instantiationService.createInstance(UntitledEditorInput, uri, false, this.cellModel.language, '', ''); this._editorInput = instantiationService.createInstance(UntitledEditorInput, uri, false, this.cellModel.language, '', '');
this._editor.setInput(this._editorInput, undefined); await this._editor.setInput(this._editorInput, undefined);
this.setFocusAndScroll(); this.setFocusAndScroll();
this._editorInput.resolve().then(model => { let untitledEditorModel: UntitledEditorModel = await this._editorInput.resolve();
this._editorModel = model.textEditorModel; if (untitledEditorModel) {
this._editorModel = untitledEditorModel.textEditorModel;
this._modelService.updateModel(this._editorModel, this.cellModel.source); this._modelService.updateModel(this._editorModel, this.cellModel.source);
}); }
let isActive = this.cellModel.id === this._activeCellId; let isActive = this.cellModel.id === this._activeCellId;
this._editor.toggleEditorSelected(isActive); this._editor.toggleEditorSelected(isActive);
@@ -177,14 +179,16 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
this._register(this._editor); this._register(this._editor);
this._register(this._editorInput); this._register(this._editorInput);
this._register(this._editorModel.onDidChangeContent(e => { if (this._editorModel) {
this._editor.setHeightToScrollHeight(); this._register(this._editorModel.onDidChangeContent(e => {
this.cellModel.source = this._editorModel.getValue(); this._editor.setHeightToScrollHeight();
this.onContentChanged.emit(); this.cellModel.source = this._editorModel.getValue();
this.checkForLanguageMagics(); this.onContentChanged.emit();
// TODO see if there's a better way to handle reassessing size. this.checkForLanguageMagics();
setTimeout(() => this._layoutEmitter.fire(), 250); // TODO see if there's a better way to handle reassessing size.
})); 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')) {
this._editor.setHeightToScrollHeight(true); this._editor.setHeightToScrollHeight(true);