Merge pull request #117100 from NotWearingPants/feature/debug-save-before-run-setting

add debug.saveBeforeRun setting
This commit is contained in:
Isidor Nikolic 2021-02-22 21:02:58 +01:00 committed by GitHub
commit ed3eb3fdf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View file

@ -489,6 +489,16 @@ function registerConfiguration(): void {
type: 'boolean',
description: nls.localize({ comment: ['This is the description for a setting'], key: 'showInlineBreakpointCandidates' }, "Controls whether inline breakpoints candidate decorations should be shown in the editor while debugging."),
default: true
},
'debug.saveBeforeStart': {
description: nls.localize('debug.saveBeforeStart', "Controls what editors to save before starting a debug session."),
enum: ['allEditorsInActiveGroup', 'nonUntitledEditorsInActiveGroup', 'none'],
enumDescriptions: [
nls.localize('debug.saveBeforeStart.allEditorsInActiveGroup', "Save all editors in the active group before starting a debug session."),
nls.localize('debug.saveBeforeStart.nonUntitledEditorsInActiveGroup', "Save all editors in the active group except untitled ones before starting a debug session."),
nls.localize('debug.saveBeforeStart.none', "Don't save any editors before starting a debug session."),
],
default: 'allEditorsInActiveGroup'
}
}
});

View file

@ -279,11 +279,17 @@ export class DebugService implements IDebugService {
// make sure to save all files and that the configuration is up to date
await this.extensionService.activateByEvent('onDebug');
if (!options?.parentSession) {
await this.editorService.saveAll();
const activeEditor = this.editorService.activeEditorPane;
if (activeEditor) {
// Make sure to save the active editor in case it is in untitled file it wont be saved as part of saveAll #111850
await this.editorService.save({ editor: activeEditor.input, groupId: activeEditor.group.id });
const saveBeforeStartConfig: string = this.configurationService.getValue('debug.saveBeforeStart');
if (saveBeforeStartConfig !== 'none') {
await this.editorService.saveAll();
if (saveBeforeStartConfig === 'allEditorsInActiveGroup') {
const activeEditor = this.editorService.activeEditorPane;
if (activeEditor) {
// Make sure to save the active editor in case it is in untitled file it wont be saved as part of saveAll #111850
await this.editorService.save({ editor: activeEditor.input, groupId: activeEditor.group.id });
}
}
}
}
await this.configurationService.reloadConfiguration(launch ? launch.workspace : undefined);