mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-14 08:28:31 -05:00
Re #96398. Fix the data loss when switching
This commit is contained in:
@@ -102,6 +102,7 @@ export interface ICellViewModel {
|
||||
currentTokenSource: CancellationTokenSource | undefined;
|
||||
focusMode: CellFocusMode;
|
||||
getText(): string;
|
||||
save(): void;
|
||||
metadata: NotebookCellMetadata | undefined;
|
||||
getEvaluatedMetadata(documentMetadata: NotebookDocumentMetadata | undefined): NotebookCellMetadata;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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}'`);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user