提交 0ccc731f 编写于 作者: J Johannes Rieken

make sure editState is CellEditState.Editing when text model changes, also...

make sure editState is CellEditState.Editing when text model changes, also make sure not to duplicate newlines,  #96398
上级 d3b60a25
...@@ -173,8 +173,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod ...@@ -173,8 +173,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
save() { save() {
if (this._textModel && !this._textModel.isDisposed() && this.editState === CellEditState.Editing) { if (this._textModel && !this._textModel.isDisposed() && this.editState === CellEditState.Editing) {
let cnt = this._textModel.getLineCount(); this.model.source = this._textModel.getLinesContent();
this.model.source = this._textModel.getLinesContent().map((str, index) => str + (index !== cnt - 1 ? '\n' : ''));
} }
} }
...@@ -185,6 +184,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod ...@@ -185,6 +184,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
this._buffer = this._textModel.getTextBuffer(); this._buffer = this._textModel.getTextBuffer();
this._register(ref); this._register(ref);
this._register(this._textModel.onDidChangeContent(() => { this._register(this._textModel.onDidChangeContent(() => {
this.editState = CellEditState.Editing;
this.model.contentChange(); this.model.contentChange();
this._onDidChangeState.fire({ contentChanged: true }); this._onDidChangeState.fire({ contentChanged: true });
})); }));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册