@@ -57,7 +57,7 @@ import { QuickInputService, QuickPickItem, QuickPickItemOrSeparator, QuickPickSe
5757import { AsyncLocalizationProvider } from '../common/i18n/localization' ;
5858import { nls } from '../common/nls' ;
5959import { CurrentWidgetCommandAdapter } from './shell/current-widget-command-adapter' ;
60- import { ConfirmDialog , confirmExitWithOrWithoutSaving , Dialog } from './dialogs' ;
60+ import { ConfirmDialog , confirmExitWithOrWithoutSaving , confirmExitWithOrWithoutSavingResult , Dialog } from './dialogs' ;
6161import { WindowService } from './window/window-service' ;
6262import { FrontendApplicationConfigProvider } from './frontend-application-config-provider' ;
6363import { DecorationStyle } from './decoration-style' ;
@@ -1200,17 +1200,16 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
12001200 action : async ( ) => {
12011201 const captionsToSave = this . unsavedTabsCaptions ( ) ;
12021202 const untitledCaptionsToSave = this . unsavedUntitledTabsCaptions ( ) ;
1203- const result = await confirmExitWithOrWithoutSaving ( captionsToSave , async ( ) => {
1203+ const shouldExit = await confirmExitWithOrWithoutSaving ( captionsToSave , async ( ) => {
12041204 await this . saveDirty ( untitledCaptionsToSave ) ;
12051205 await this . shell . saveAll ( ) ;
12061206 } ) ;
1207- if ( this . shell . canSaveAll ( ) ) {
1208- this . shouldPreventClose = true ;
1209- return false ;
1210- } else {
1211- this . shouldPreventClose = false ;
1212- return result ;
1213- }
1207+ const allSavedOrDoNotSave = (
1208+ confirmExitWithOrWithoutSavingResult . save === shouldExit && untitledCaptionsToSave . length === 0 // cancel if any captions failed to save
1209+ ) || confirmExitWithOrWithoutSavingResult . doNotSave === shouldExit ;
1210+
1211+ this . shouldPreventClose = ! allSavedOrDoNotSave ;
1212+ return allSavedOrDoNotSave ;
12141213
12151214 }
12161215 } ;
@@ -1236,11 +1235,19 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
12361235 this . windowService . reload ( ) ;
12371236 }
12381237 }
1238+ /**
1239+ * saves any dirty widget in toSave
1240+ * side effect - will pop all widgets from toSave that was saved
1241+ * @param toSave
1242+ */
12391243 protected async saveDirty ( toSave : Widget [ ] ) : Promise < void > {
12401244 for ( const widget of toSave ) {
12411245 const saveable = Saveable . get ( widget ) ;
12421246 if ( saveable ?. dirty ) {
12431247 await this . saveResourceService . save ( widget ) ;
1248+ if ( ! this . saveResourceService . canSave ( widget ) ) {
1249+ toSave . pop ( ) ;
1250+ }
12441251 }
12451252 }
12461253 }
0 commit comments