mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-20 02:34:37 +01:00
Check save settings before debug restart (#154206)
* Fix bug: Files automatically saved when restarting debugger, even though it is set not to Fixes #149885
This commit is contained in:
@@ -223,6 +223,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
||||
const folderUri = folder ? uri.revive(folder) : undefined;
|
||||
const launch = this.debugService.getConfigurationManager().getLaunch(folderUri);
|
||||
const parentSession = this.getSession(options.parentSessionID);
|
||||
const saveBeforeStart = typeof options.suppressSaveBeforeStart === 'boolean' ? !options.suppressSaveBeforeStart : undefined;
|
||||
const debugOptions: IDebugSessionOptions = {
|
||||
noDebug: options.noDebug,
|
||||
parentSession,
|
||||
@@ -230,11 +231,11 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
||||
repl: options.repl,
|
||||
compact: options.compact,
|
||||
debugUI: options.debugUI,
|
||||
compoundRoot: parentSession?.compoundRoot
|
||||
compoundRoot: parentSession?.compoundRoot,
|
||||
saveBeforeStart: saveBeforeStart
|
||||
};
|
||||
try {
|
||||
const saveBeforeStart = typeof options.suppressSaveBeforeStart === 'boolean' ? !options.suppressSaveBeforeStart : undefined;
|
||||
return this.debugService.startDebugging(launch, nameOrConfig, debugOptions, saveBeforeStart);
|
||||
return this.debugService.startDebugging(launch, nameOrConfig, debugOptions);
|
||||
} catch (err) {
|
||||
throw new ErrorNoTelemetry(err && err.message ? err.message : 'cannot start debugging');
|
||||
}
|
||||
|
||||
@@ -723,7 +723,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
const { 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, startedByUser: true }, false);
|
||||
await debugService.startDebugging(launch, configOrName, { noDebug: debugStartOptions?.noDebug, startedByUser: true, saveBeforeStart: false });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -312,7 +312,10 @@ 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, saveBeforeStart = !options?.parentSession): Promise<boolean> {
|
||||
async startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions): Promise<boolean> {
|
||||
|
||||
const saveBeforeStart = options?.saveBeforeStart ?? !options?.parentSession;
|
||||
|
||||
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) {
|
||||
@@ -701,7 +704,10 @@ export class DebugService implements IDebugService {
|
||||
}
|
||||
|
||||
async restartSession(session: IDebugSession, restartData?: any): Promise<any> {
|
||||
await this.editorService.saveAll();
|
||||
if (session.saveBeforeStart) {
|
||||
await saveAllBeforeDebugStart(this.configurationService, this.editorService);
|
||||
}
|
||||
|
||||
const isAutoRestart = !!restartData;
|
||||
|
||||
const runTasks: () => Promise<TaskRunResult> = async () => {
|
||||
|
||||
@@ -164,6 +164,10 @@ export class DebugSession implements IDebugSession {
|
||||
return !!this._options.compact;
|
||||
}
|
||||
|
||||
get saveBeforeStart(): boolean {
|
||||
return this._options.saveBeforeStart ?? !this._options?.parentSession;
|
||||
}
|
||||
|
||||
get compoundRoot(): DebugCompoundRoot | undefined {
|
||||
return this._options.compoundRoot;
|
||||
}
|
||||
|
||||
@@ -206,6 +206,7 @@ export interface IDebugSessionOptions {
|
||||
simple?: boolean;
|
||||
};
|
||||
startedByUser?: boolean;
|
||||
saveBeforeStart?: boolean;
|
||||
}
|
||||
|
||||
export interface IDataBreakpointInfoResponse {
|
||||
@@ -296,6 +297,7 @@ export interface IDebugSession extends ITreeElement {
|
||||
readonly subId: string | undefined;
|
||||
readonly compact: boolean;
|
||||
readonly compoundRoot: DebugCompoundRoot | undefined;
|
||||
readonly saveBeforeStart: boolean;
|
||||
readonly name: string;
|
||||
readonly isSimpleUI: boolean;
|
||||
readonly autoExpandLazyVariables: boolean;
|
||||
@@ -1088,7 +1090,7 @@ export interface IDebugService {
|
||||
* Returns true if the start debugging was successful. For compound launches, all configurations have to start successfully 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, saveBeforeStart?: boolean): Promise<boolean>;
|
||||
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Restarts a session or creates a new one if there is no active session.
|
||||
|
||||
@@ -190,6 +190,10 @@ export class MockSession implements IDebugSession {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get saveBeforeStart(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
get isSimpleUI(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user