Skip to content

Commit

Permalink
Fix Debugger Restart Bug (#158184)
Browse files Browse the repository at this point in the history
* VS Code pre-release does not reload code on restart of the debugger
Fixes #157655
  • Loading branch information
andreamah committed Aug 15, 2022
1 parent 3d54f31 commit e4503b3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/vs/workbench/api/browser/mainThreadDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
compact: options.compact,
debugUI: options.debugUI,
compoundRoot: parentSession?.compoundRoot,
saveBeforeStart: saveBeforeStart
saveBeforeRestart: saveBeforeStart
};
try {
return this.debugService.startDebugging(launch, nameOrConfig, debugOptions);
return this.debugService.startDebugging(launch, nameOrConfig, debugOptions, saveBeforeStart);
} catch (err) {
throw new ErrorNoTelemetry(err && err.message ? err.message : 'cannot start debugging');
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/debug/browser/debugCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,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, saveBeforeStart: false });
await debugService.startDebugging(launch, configOrName, { noDebug: debugStartOptions?.noDebug, startedByUser: true }, false);
}
});

Expand Down
7 changes: 2 additions & 5 deletions src/vs/workbench/contrib/debug/browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,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> {

const saveBeforeStart = options?.saveBeforeStart ?? !options?.parentSession;

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) {
Expand Down Expand Up @@ -704,7 +701,7 @@ export class DebugService implements IDebugService {
}

async restartSession(session: IDebugSession, restartData?: any): Promise<any> {
if (session.saveBeforeStart) {
if (session.saveBeforeRestart) {
await saveAllBeforeDebugStart(this.configurationService, this.editorService);
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/debug/browser/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export class DebugSession implements IDebugSession {
return !!this._options.compact;
}

get saveBeforeStart(): boolean {
return this._options.saveBeforeStart ?? !this._options?.parentSession;
get saveBeforeRestart(): boolean {
return this._options.saveBeforeRestart ?? !this._options?.parentSession;
}

get compoundRoot(): DebugCompoundRoot | undefined {
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export interface IDebugSessionOptions {
simple?: boolean;
};
startedByUser?: boolean;
saveBeforeStart?: boolean;
saveBeforeRestart?: boolean;
}

export interface IDataBreakpointInfoResponse {
Expand Down Expand Up @@ -297,7 +297,7 @@ export interface IDebugSession extends ITreeElement {
readonly subId: string | undefined;
readonly compact: boolean;
readonly compoundRoot: DebugCompoundRoot | undefined;
readonly saveBeforeStart: boolean;
readonly saveBeforeRestart: boolean;
readonly name: string;
readonly isSimpleUI: boolean;
readonly autoExpandLazyVariables: boolean;
Expand Down Expand Up @@ -1090,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): 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.
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/debug/test/browser/mockDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class MockSession implements IDebugSession {
return undefined;
}

get saveBeforeStart(): boolean {
get saveBeforeRestart(): boolean {
return true;
}

Expand Down

0 comments on commit e4503b3

Please sign in to comment.