Merge pull request #172595 from amunger/aamunger/IWBackups

save IW before shutdown to discard working copy backup
This commit is contained in:
Aaron Munger
2023-01-26 15:30:41 -08:00
committed by GitHub

View File

@@ -18,6 +18,7 @@ import { EditorModel } from 'vs/workbench/common/editor/editorModel';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
import { ICellDto2, INotebookEditorModel, INotebookLoadOptions, IResolvedNotebookEditorModel, NotebookCellsChangeType, NotebookData } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookSerializer, INotebookService, SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService';
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { IFileWorkingCopyManager } from 'vs/workbench/services/workingCopy/common/fileWorkingCopyManager';
import { IStoredFileWorkingCopy, IStoredFileWorkingCopyModel, IStoredFileWorkingCopyModelContentChangedEvent, IStoredFileWorkingCopyModelFactory, IStoredFileWorkingCopySaveEvent, StoredFileWorkingCopyState } from 'vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
import { IUntitledFileWorkingCopy, IUntitledFileWorkingCopyModel, IUntitledFileWorkingCopyModelContentChangedEvent, IUntitledFileWorkingCopyModelFactory } from 'vs/workbench/services/workingCopy/common/untitledFileWorkingCopy';
@@ -45,9 +46,21 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
private readonly _hasAssociatedFilePath: boolean,
readonly viewType: string,
private readonly _workingCopyManager: IFileWorkingCopyManager<NotebookFileWorkingCopyModel, NotebookFileWorkingCopyModel>,
@IFileService private readonly _fileService: IFileService
@IFileService private readonly _fileService: IFileService,
@ILifecycleService lifecycleService: ILifecycleService
) {
super();
if (this.viewType === 'interactive') {
lifecycleService.onBeforeShutdown(async e => e.veto(this.onBeforeShutdown(), 'veto.InteractiveWindow'));
}
}
private async onBeforeShutdown() {
if (this._workingCopy?.isDirty()) {
await this._workingCopy.save();
}
return false;
}
override dispose(): void {