@@ -83,6 +83,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
83
83
private loadedPromise : Deferred < void > = createDeferred < void > ( ) ;
84
84
private _file : Uri = Uri . file ( '' ) ;
85
85
private _dirty : boolean = false ;
86
+ private isPromptingToSaveToDisc : boolean = false ;
86
87
private visibleCells : ICell [ ] = [ ] ;
87
88
private startupTimer : StopWatch = new StopWatch ( ) ;
88
89
private loadedAllCells : boolean = false ;
@@ -837,12 +838,18 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
837
838
838
839
@captureTelemetry ( Telemetry . Save , undefined , true )
839
840
private async saveToDisk ( ) : Promise < void > {
841
+ // If we're already in the middle of prompting the user to save, then get out of here.
842
+ // We could add a debounce decorator, unfortunately that slows saving (by waiting for no more save events to get sent).
843
+ if ( this . isPromptingToSaveToDisc && this . isUntitled ) {
844
+ return ;
845
+ }
840
846
try {
841
847
let fileToSaveTo : Uri | undefined = this . file ;
842
848
let isDirty = this . _dirty ;
843
849
844
850
// Ask user for a save as dialog if no title
845
851
if ( this . isUntitled ) {
852
+ this . isPromptingToSaveToDisc = true ;
846
853
const filtersKey = localize . DataScience . dirtyNotebookDialogFilter ( ) ;
847
854
const filtersObject : { [ name : string ] : string [ ] } = { } ;
848
855
filtersObject [ filtersKey ] = [ 'ipynb' ] ;
@@ -865,6 +872,8 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
865
872
}
866
873
} catch ( e ) {
867
874
traceError ( e ) ;
875
+ } finally {
876
+ this . isPromptingToSaveToDisc = false ;
868
877
}
869
878
}
870
879
0 commit comments