#4225: Markdown content disappears when edit (#4249)

This commit is contained in:
Raj
2019-02-28 19:18:40 -08:00
committed by GitHub
parent 630698459b
commit 18970ff0b9

View File

@@ -188,33 +188,27 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange
this._editor.setMinimumHeight(this._minimumHeight); this._editor.setMinimumHeight(this._minimumHeight);
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.cellModel.source, '');
await this._editor.setInput(this._editorInput, undefined); await this._editor.setInput(this._editorInput, undefined);
this.setFocusAndScroll(); this.setFocusAndScroll();
let untitledEditorModel: UntitledEditorModel = await this._editorInput.resolve(); let untitledEditorModel: UntitledEditorModel = await this._editorInput.resolve();
if (untitledEditorModel) { this._editorModel = untitledEditorModel.textEditorModel;
this._editorModel = untitledEditorModel.textEditorModel;
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);
// For markdown cells, don't show line numbers unless we're using editor defaults // For markdown cells, don't show line numbers unless we're using editor defaults
let overrideEditorSetting = this._configurationService.getValue<boolean>(OVERRIDE_EDITOR_THEMING_SETTING); let overrideEditorSetting = this._configurationService.getValue<boolean>(OVERRIDE_EDITOR_THEMING_SETTING);
this._editor.hideLineNumbers = (overrideEditorSetting && this.cellModel.cellType === CellTypes.Markdown); this._editor.hideLineNumbers = (overrideEditorSetting && this.cellModel.cellType === CellTypes.Markdown);
this._register(this._editor); this._register(this._editor);
this._register(this._editorInput); this._register(this._editorInput);
if (this._editorModel) { this._register(this._editorModel.onDidChangeContent(e => {
this._register(this._editorModel.onDidChangeContent(e => { this._editor.setHeightToScrollHeight();
this._editor.setHeightToScrollHeight(); this.cellModel.source = this._editorModel.getValue();
this.cellModel.source = this._editorModel.getValue(); this.onContentChanged.emit();
this.onContentChanged.emit(); this.checkForLanguageMagics();
this.checkForLanguageMagics(); // TODO see if there's a better way to handle reassessing size.
// TODO see if there's a better way to handle reassessing size. 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')) {
this._editor.setHeightToScrollHeight(true); this._editor.setHeightToScrollHeight(true);