@@ -18,6 +18,7 @@ import { EditorModel } from 'vs/workbench/common/editor/editorModel';
18
18
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel' ;
19
19
import { ICellDto2 , INotebookEditorModel , INotebookLoadOptions , IResolvedNotebookEditorModel , NotebookCellsChangeType , NotebookData } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
20
20
import { INotebookSerializer , INotebookService , SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService' ;
21
+ import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle' ;
21
22
import { IFileWorkingCopyManager } from 'vs/workbench/services/workingCopy/common/fileWorkingCopyManager' ;
22
23
import { IStoredFileWorkingCopy , IStoredFileWorkingCopyModel , IStoredFileWorkingCopyModelContentChangedEvent , IStoredFileWorkingCopyModelFactory , IStoredFileWorkingCopySaveEvent , StoredFileWorkingCopyState } from 'vs/workbench/services/workingCopy/common/storedFileWorkingCopy' ;
23
24
import { IUntitledFileWorkingCopy , IUntitledFileWorkingCopyModel , IUntitledFileWorkingCopyModelContentChangedEvent , IUntitledFileWorkingCopyModelFactory } from 'vs/workbench/services/workingCopy/common/untitledFileWorkingCopy' ;
@@ -45,9 +46,21 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
45
46
private readonly _hasAssociatedFilePath : boolean ,
46
47
readonly viewType : string ,
47
48
private readonly _workingCopyManager : IFileWorkingCopyManager < NotebookFileWorkingCopyModel , NotebookFileWorkingCopyModel > ,
48
- @IFileService private readonly _fileService : IFileService
49
+ @IFileService private readonly _fileService : IFileService ,
50
+ @ILifecycleService lifecycleService : ILifecycleService
49
51
) {
50
52
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 ;
51
64
}
52
65
53
66
override dispose ( ) : void {
0 commit comments