Re #96398. Fix the data loss when switching

This commit is contained in:
rebornix
2020-04-29 10:39:27 -07:00
parent 507345d7e9
commit da88f129d3
4 changed files with 9 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ export interface ICellViewModel {
currentTokenSource: CancellationTokenSource | undefined;
focusMode: CellFocusMode;
getText(): string;
save(): void;
metadata: NotebookCellMetadata | undefined;
getEvaluatedMetadata(documentMetadata: NotebookDocumentMetadata | undefined): NotebookCellMetadata;
}

View File

@@ -636,6 +636,8 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
state.contributionsState = contributionsState;
this.editorMemento.saveEditorState(this.group, input.resource, state);
this.notebookViewModel.viewCells.forEach(cell => cell.save());
}
}

View File

@@ -173,6 +173,10 @@ export class NotebookEditorInput extends EditorInput {
}
async resolve(): Promise<NotebookEditorModel> {
if (this.textModel) {
return this.textModel;
}
if (!this.promise) {
if (!await this.notebookService.canResolve(this.viewType!)) {
throw new Error(`Cannot open notebook of type '${this.viewType}'`);

View File

@@ -199,6 +199,8 @@ export abstract class BaseCellViewModel extends Disposable implements ICellViewM
return this.model.source.join('\n');
}
abstract save(): void;
private saveViewState(): editorCommon.ICodeEditorViewState | null {
if (!this._textEditor) {
return null;