Skip to content

Commit e4503b3

Browse files
authored
Fix Debugger Restart Bug (#158184)
* VS Code pre-release does not reload code on restart of the debugger Fixes #157655
1 parent 3d54f31 commit e4503b3

6 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/vs/workbench/api/browser/mainThreadDebugService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
232232
compact: options.compact,
233233
debugUI: options.debugUI,
234234
compoundRoot: parentSession?.compoundRoot,
235-
saveBeforeStart: saveBeforeStart
235+
saveBeforeRestart: saveBeforeStart
236236
};
237237
try {
238-
return this.debugService.startDebugging(launch, nameOrConfig, debugOptions);
238+
return this.debugService.startDebugging(launch, nameOrConfig, debugOptions, saveBeforeStart);
239239
} catch (err) {
240240
throw new ErrorNoTelemetry(err && err.message ? err.message : 'cannot start debugging');
241241
}

src/vs/workbench/contrib/debug/browser/debugCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
731731
const { launch, name, getConfig } = debugService.getConfigurationManager().selectedConfiguration;
732732
const config = await getConfig();
733733
const configOrName = config ? Object.assign(deepClone(config), debugStartOptions?.config) : name;
734-
await debugService.startDebugging(launch, configOrName, { noDebug: debugStartOptions?.noDebug, startedByUser: true, saveBeforeStart: false });
734+
await debugService.startDebugging(launch, configOrName, { noDebug: debugStartOptions?.noDebug, startedByUser: true }, false);
735735
}
736736
});
737737

src/vs/workbench/contrib/debug/browser/debugService.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,7 @@ export class DebugService implements IDebugService {
312312
* main entry point
313313
* properly manages compounds, checks for errors and handles the initializing state.
314314
*/
315-
async startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions): Promise<boolean> {
316-
317-
const saveBeforeStart = options?.saveBeforeStart ?? !options?.parentSession;
318-
315+
async startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions, saveBeforeStart = !options?.parentSession): Promise<boolean> {
319316
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.");
320317
const trust = await this.workspaceTrustRequestService.requestWorkspaceTrust({ message });
321318
if (!trust) {
@@ -704,7 +701,7 @@ export class DebugService implements IDebugService {
704701
}
705702

706703
async restartSession(session: IDebugSession, restartData?: any): Promise<any> {
707-
if (session.saveBeforeStart) {
704+
if (session.saveBeforeRestart) {
708705
await saveAllBeforeDebugStart(this.configurationService, this.editorService);
709706
}
710707

src/vs/workbench/contrib/debug/browser/debugSession.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ export class DebugSession implements IDebugSession {
164164
return !!this._options.compact;
165165
}
166166

167-
get saveBeforeStart(): boolean {
168-
return this._options.saveBeforeStart ?? !this._options?.parentSession;
167+
get saveBeforeRestart(): boolean {
168+
return this._options.saveBeforeRestart ?? !this._options?.parentSession;
169169
}
170170

171171
get compoundRoot(): DebugCompoundRoot | undefined {

src/vs/workbench/contrib/debug/common/debug.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export interface IDebugSessionOptions {
206206
simple?: boolean;
207207
};
208208
startedByUser?: boolean;
209-
saveBeforeStart?: boolean;
209+
saveBeforeRestart?: boolean;
210210
}
211211

212212
export interface IDataBreakpointInfoResponse {
@@ -297,7 +297,7 @@ export interface IDebugSession extends ITreeElement {
297297
readonly subId: string | undefined;
298298
readonly compact: boolean;
299299
readonly compoundRoot: DebugCompoundRoot | undefined;
300-
readonly saveBeforeStart: boolean;
300+
readonly saveBeforeRestart: boolean;
301301
readonly name: string;
302302
readonly isSimpleUI: boolean;
303303
readonly autoExpandLazyVariables: boolean;
@@ -1090,7 +1090,7 @@ export interface IDebugService {
10901090
* Returns true if the start debugging was successful. For compound launches, all configurations have to start successfully for it to return success.
10911091
* On errors the startDebugging will throw an error, however some error and cancelations are handled and in that case will simply return false.
10921092
*/
1093-
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions): Promise<boolean>;
1093+
startDebugging(launch: ILaunch | undefined, configOrName?: IConfig | string, options?: IDebugSessionOptions, saveBeforeStart?: boolean): Promise<boolean>;
10941094

10951095
/**
10961096
* Restarts a session or creates a new one if there is no active session.

src/vs/workbench/contrib/debug/test/browser/mockDebug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class MockSession implements IDebugSession {
190190
return undefined;
191191
}
192192

193-
get saveBeforeStart(): boolean {
193+
get saveBeforeRestart(): boolean {
194194
return true;
195195
}
196196

0 commit comments

Comments
 (0)