Skip to content

Commit acbbdaa

Browse files
authored
Merge pull request microsoft#172595 from amunger/aamunger/IWBackups
save IW before shutdown to discard working copy backup
2 parents 5efc2a4 + 9534fa8 commit acbbdaa

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { EditorModel } from 'vs/workbench/common/editor/editorModel';
1818
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
1919
import { ICellDto2, INotebookEditorModel, INotebookLoadOptions, IResolvedNotebookEditorModel, NotebookCellsChangeType, NotebookData } from 'vs/workbench/contrib/notebook/common/notebookCommon';
2020
import { INotebookSerializer, INotebookService, SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService';
21+
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
2122
import { IFileWorkingCopyManager } from 'vs/workbench/services/workingCopy/common/fileWorkingCopyManager';
2223
import { IStoredFileWorkingCopy, IStoredFileWorkingCopyModel, IStoredFileWorkingCopyModelContentChangedEvent, IStoredFileWorkingCopyModelFactory, IStoredFileWorkingCopySaveEvent, StoredFileWorkingCopyState } from 'vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
2324
import { IUntitledFileWorkingCopy, IUntitledFileWorkingCopyModel, IUntitledFileWorkingCopyModelContentChangedEvent, IUntitledFileWorkingCopyModelFactory } from 'vs/workbench/services/workingCopy/common/untitledFileWorkingCopy';
@@ -45,9 +46,21 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
4546
private readonly _hasAssociatedFilePath: boolean,
4647
readonly viewType: string,
4748
private readonly _workingCopyManager: IFileWorkingCopyManager<NotebookFileWorkingCopyModel, NotebookFileWorkingCopyModel>,
48-
@IFileService private readonly _fileService: IFileService
49+
@IFileService private readonly _fileService: IFileService,
50+
@ILifecycleService lifecycleService: ILifecycleService
4951
) {
5052
super();
53+
54+
if (this.viewType === 'interactive') {
55+
lifecycleService.onBeforeShutdown(async e => e.veto(this.onBeforeShutdown(), 'veto.InteractiveWindow'));
56+
}
57+
}
58+
59+
private async onBeforeShutdown() {
60+
if (this._workingCopy?.isDirty()) {
61+
await this._workingCopy.save();
62+
}
63+
return false;
5164
}
5265

5366
override dispose(): void {

0 commit comments

Comments
 (0)