make sure to save launch config before debugging starts to have freshest content
fixes #125259
This commit is contained in:
parent
0dbbb58191
commit
1fd7873cee
5 changed files with 26 additions and 18 deletions
|
@ -30,6 +30,7 @@ import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
|||
import { IViewsService } from 'vs/workbench/common/views';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { isWeb, isWindows } from 'vs/base/common/platform';
|
||||
import { saveAllBeforeDebugStart } from 'vs/workbench/contrib/debug/common/debugUtils';
|
||||
|
||||
export const ADD_CONFIGURATION_ID = 'debug.addConfiguration';
|
||||
export const TOGGLE_INLINE_BREAKPOINT_ID = 'editor.debug.action.toggleInlineBreakpoint';
|
||||
|
@ -421,10 +422,11 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||
when: ContextKeyExpr.and(CONTEXT_DEBUGGERS_AVAILABLE, CONTEXT_DEBUG_STATE.isEqualTo('inactive')),
|
||||
handler: async (accessor: ServicesAccessor, debugStartOptions?: { config?: Partial<IConfig>; noDebug?: boolean }) => {
|
||||
const debugService = accessor.get(IDebugService);
|
||||
await saveAllBeforeDebugStart(accessor.get(IConfigurationService), accessor.get(IEditorService));
|
||||
let { launch, name, getConfig } = debugService.getConfigurationManager().selectedConfiguration;
|
||||
const config = await getConfig();
|
||||
const configOrName = config ? Object.assign(deepClone(config), debugStartOptions?.config) : name;
|
||||
await debugService.startDebugging(launch, configOrName, { noDebug: debugStartOptions?.noDebug });
|
||||
await debugService.startDebugging(launch, configOrName, { noDebug: debugStartOptions?.noDebug }, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -371,7 +371,7 @@ export class ConfigurationManager implements IConfigurationManager {
|
|||
}
|
||||
|
||||
const names = launch ? launch.getConfigurationNames() : [];
|
||||
this.getSelectedConfig = () => Promise.resolve(config);
|
||||
this.getSelectedConfig = () => Promise.resolve(this.selectedName ? launch?.getConfiguration(this.selectedName) : undefined);
|
||||
let type = config?.type;
|
||||
if (name && names.indexOf(name) >= 0) {
|
||||
this.setSelectedLaunchName(name);
|
||||
|
|
|
@ -31,7 +31,7 @@ import { deepClone, equals } from 'vs/base/common/objects';
|
|||
import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDebugService, State, IDebugSession, CONTEXT_DEBUG_TYPE, CONTEXT_DEBUG_STATE, CONTEXT_IN_DEBUG_MODE, IThread, IDebugConfiguration, VIEWLET_ID, IConfig, ILaunch, IViewModel, IConfigurationManager, IDebugModel, IEnablement, IBreakpoint, IBreakpointData, ICompound, IStackFrame, getStateLabel, IDebugSessionOptions, CONTEXT_DEBUG_UX, REPL_VIEW_ID, CONTEXT_BREAKPOINTS_EXIST, IGlobalConfig, CALLSTACK_VIEW_ID, IAdapterManager, IExceptionBreakpoint, CONTEXT_DISASSEMBLY_VIEW_FOCUS } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { getExtensionHostDebugSession } from 'vs/workbench/contrib/debug/common/debugUtils';
|
||||
import { getExtensionHostDebugSession, saveAllBeforeDebugStart } from 'vs/workbench/contrib/debug/common/debugUtils';
|
||||
import { raceTimeout, RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { IExtensionHostDebugService } from 'vs/platform/debug/common/extensionHostDebug';
|
||||
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
@ -301,7 +301,7 @@ export class DebugService implements IDebugService {
|
|||
* main entry point
|
||||
* properly manages compounds, checks for errors and handles the initializing state.
|
||||
*/
|
||||
async startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions): Promise<boolean> {
|
||||
async startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions, saveBeforeStart = !options?.parentSession): Promise<boolean> {
|
||||
const message = options && options.noDebug ? nls.localize('runTrust', "Running executes build tasks and program code from your workspace.") : nls.localize('debugTrust', "Debugging executes build tasks and program code from your workspace.");
|
||||
const trust = await this.workspaceTrustRequestService.requestWorkspaceTrust({ message });
|
||||
if (!trust) {
|
||||
|
@ -311,20 +311,9 @@ export class DebugService implements IDebugService {
|
|||
try {
|
||||
// make sure to save all files and that the configuration is up to date
|
||||
await this.extensionService.activateByEvent('onDebug');
|
||||
if (!options?.parentSession) {
|
||||
const saveBeforeStartConfig: string = this.configurationService.getValue('debug.saveBeforeStart', { overrideIdentifier: this.editorService.activeTextEditorMode });
|
||||
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 });
|
||||
if (saveBeforeStart) {
|
||||
await saveAllBeforeDebugStart(this.configurationService, this.editorService);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.configurationService.reloadConfiguration(launch ? launch.workspace : undefined);
|
||||
await this.extensionService.whenInstalledExtensionsRegistered();
|
||||
|
||||
let config: IConfig | undefined;
|
||||
|
|
|
@ -961,7 +961,7 @@ export interface IDebugService {
|
|||
* Returns true if the start debugging was successfull. For compound launches, all configurations have to start successfuly for it to return success.
|
||||
* On errors the startDebugging will throw an error, however some error and cancelations are handled and in that case will simply return false.
|
||||
*/
|
||||
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions): Promise<boolean>;
|
||||
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions, saveBeforeStart?: boolean): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Restarts a session or creates a new one if there is no active session.
|
||||
|
|
|
@ -9,6 +9,8 @@ import { URI as uri } from 'vs/base/common/uri';
|
|||
import { isAbsolute } from 'vs/base/common/path';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
const _formatPIIRegexp = /{([^}]+)}/g;
|
||||
|
||||
|
@ -303,3 +305,18 @@ function compareOrders(first: number | undefined, second: number | undefined): n
|
|||
|
||||
return first - second;
|
||||
}
|
||||
|
||||
export async function saveAllBeforeDebugStart(configurationService: IConfigurationService, editorService: IEditorService): Promise<void> {
|
||||
const saveBeforeStartConfig: string = configurationService.getValue('debug.saveBeforeStart', { overrideIdentifier: editorService.activeTextEditorMode });
|
||||
if (saveBeforeStartConfig !== 'none') {
|
||||
await editorService.saveAll();
|
||||
if (saveBeforeStartConfig === 'allEditorsInActiveGroup') {
|
||||
const activeEditor = 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 editorService.save({ editor: activeEditor.input, groupId: activeEditor.group.id });
|
||||
}
|
||||
}
|
||||
}
|
||||
await configurationService.reloadConfiguration();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue