@@ -18,6 +18,7 @@ import { EditorModel } from 'vs/workbench/common/editor/editorModel';
1818import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel' ;
1919import { ICellDto2 , INotebookEditorModel , INotebookLoadOptions , IResolvedNotebookEditorModel , NotebookCellsChangeType , NotebookData } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
2020import { INotebookSerializer , INotebookService , SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService' ;
21+ import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle' ;
2122import { IFileWorkingCopyManager } from 'vs/workbench/services/workingCopy/common/fileWorkingCopyManager' ;
2223import { IStoredFileWorkingCopy , IStoredFileWorkingCopyModel , IStoredFileWorkingCopyModelContentChangedEvent , IStoredFileWorkingCopyModelFactory , IStoredFileWorkingCopySaveEvent , StoredFileWorkingCopyState } from 'vs/workbench/services/workingCopy/common/storedFileWorkingCopy' ;
2324import { 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