Skip to content

Commit 0ccc731

Browse files
committed
make sure editState is CellEditState.Editing when text model changes, also make sure not to duplicate newlines, microsoft#96398
1 parent d3b60a2 commit 0ccc731

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
173173

174174
save() {
175175
if (this._textModel && !this._textModel.isDisposed() && this.editState === CellEditState.Editing) {
176-
let cnt = this._textModel.getLineCount();
177-
this.model.source = this._textModel.getLinesContent().map((str, index) => str + (index !== cnt - 1 ? '\n' : ''));
176+
this.model.source = this._textModel.getLinesContent();
178177
}
179178
}
180179

@@ -185,6 +184,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
185184
this._buffer = this._textModel.getTextBuffer();
186185
this._register(ref);
187186
this._register(this._textModel.onDidChangeContent(() => {
187+
this.editState = CellEditState.Editing;
188188
this.model.contentChange();
189189
this._onDidChangeState.fire({ contentChanged: true });
190190
}));

0 commit comments

Comments
 (0)