@@ -57,7 +57,7 @@ import { QuickInputService, QuickPickItem, QuickPickItemOrSeparator, QuickPickSe
57
57
import { AsyncLocalizationProvider } from '../common/i18n/localization' ;
58
58
import { nls } from '../common/nls' ;
59
59
import { CurrentWidgetCommandAdapter } from './shell/current-widget-command-adapter' ;
60
- import { ConfirmDialog , confirmExitWithOrWithoutSaving , Dialog } from './dialogs' ;
60
+ import { ConfirmDialog , confirmExitWithOrWithoutSaving , confirmExitWithOrWithoutSavingResult , Dialog } from './dialogs' ;
61
61
import { WindowService } from './window/window-service' ;
62
62
import { FrontendApplicationConfigProvider } from './frontend-application-config-provider' ;
63
63
import { DecorationStyle } from './decoration-style' ;
@@ -1200,17 +1200,16 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
1200
1200
action : async ( ) => {
1201
1201
const captionsToSave = this . unsavedTabsCaptions ( ) ;
1202
1202
const untitledCaptionsToSave = this . unsavedUntitledTabsCaptions ( ) ;
1203
- const result = await confirmExitWithOrWithoutSaving ( captionsToSave , async ( ) => {
1203
+ const shouldExit = await confirmExitWithOrWithoutSaving ( captionsToSave , async ( ) => {
1204
1204
await this . saveDirty ( untitledCaptionsToSave ) ;
1205
1205
await this . shell . saveAll ( ) ;
1206
1206
} ) ;
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
1209
+ ) || confirmExitWithOrWithoutSavingResult . doNotSave === shouldExit ;
1210
+
1211
+ this . shouldPreventClose = ! allSavedOrDoNotSave ;
1212
+ return allSavedOrDoNotSave ;
1214
1213
1215
1214
}
1216
1215
} ;
@@ -1236,11 +1235,19 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
1236
1235
this . windowService . reload ( ) ;
1237
1236
}
1238
1237
}
1238
+ /**
1239
+ * saves any dirty widget in toSave
1240
+ * side effect - will pop all widgets from toSave that was saved
1241
+ * @param toSave
1242
+ */
1239
1243
protected async saveDirty ( toSave : Widget [ ] ) : Promise < void > {
1240
1244
for ( const widget of toSave ) {
1241
1245
const saveable = Saveable . get ( widget ) ;
1242
1246
if ( saveable ?. dirty ) {
1243
1247
await this . saveResourceService . save ( widget ) ;
1248
+ if ( ! this . saveResourceService . canSave ( widget ) ) {
1249
+ toSave . pop ( ) ;
1250
+ }
1244
1251
}
1245
1252
}
1246
1253
}
0 commit comments