Skip to content

Commit

Permalink
debug session: pass configuration as args for restart
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Apr 16, 2021
1 parent 5d72ea7 commit 4430569
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
65 changes: 33 additions & 32 deletions src/vs/workbench/contrib/debug/browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,39 @@ export class DebugService implements IDebugService {
return;
}

// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
let needsToSubstitute = false;
let unresolved: IConfig | undefined;
const launch = session.root ? this.configurationManager.getLaunch(session.root.uri) : undefined;
if (launch) {
unresolved = launch.getConfiguration(session.configuration.name);
if (unresolved && !equals(unresolved, session.unresolvedConfiguration)) {
// Take the type from the session since the debug extension might overwrite it #21316
unresolved.type = session.configuration.type;
unresolved.noDebug = session.configuration.noDebug;
needsToSubstitute = true;
}
}

let resolved: IConfig | undefined | null = session.configuration;
if (launch && needsToSubstitute && unresolved) {
const initCancellationToken = new CancellationTokenSource();
this.sessionCancellationTokens.set(session.getId(), initCancellationToken);
const resolvedByProviders = await this.configurationManager.resolveConfigurationByProviders(launch.workspace ? launch.workspace.uri : undefined, unresolved.type, unresolved, initCancellationToken.token);
if (resolvedByProviders) {
resolved = await this.substituteVariables(launch, resolvedByProviders);
if (resolved && !initCancellationToken.token.isCancellationRequested) {
resolved = await this.configurationManager.resolveDebugConfigurationWithSubstitutedVariables(launch && launch.workspace ? launch.workspace.uri : undefined, unresolved.type, resolved, initCancellationToken.token);
}
} else {
resolved = resolvedByProviders;
}
}
if (resolved) {
session.setConfiguration({ resolved, unresolved });
}
session.configuration.__restart = restartData;

if (session.capabilities.supportsRestartRequest) {
const taskResult = await runTasks();
if (taskResult === TaskRunResult.Success) {
Expand All @@ -699,42 +732,10 @@ export class DebugService implements IDebugService {
return;
}

// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
let needsToSubstitute = false;
let unresolved: IConfig | undefined;
const launch = session.root ? this.configurationManager.getLaunch(session.root.uri) : undefined;
if (launch) {
unresolved = launch.getConfiguration(session.configuration.name);
if (unresolved && !equals(unresolved, session.unresolvedConfiguration)) {
// Take the type from the session since the debug extension might overwrite it #21316
unresolved.type = session.configuration.type;
unresolved.noDebug = session.configuration.noDebug;
needsToSubstitute = true;
}
}

let resolved: IConfig | undefined | null = session.configuration;
if (launch && needsToSubstitute && unresolved) {
const initCancellationToken = new CancellationTokenSource();
this.sessionCancellationTokens.set(session.getId(), initCancellationToken);
const resolvedByProviders = await this.configurationManager.resolveConfigurationByProviders(launch.workspace ? launch.workspace.uri : undefined, unresolved.type, unresolved, initCancellationToken.token);
if (resolvedByProviders) {
resolved = await this.substituteVariables(launch, resolvedByProviders);
if (resolved && !initCancellationToken.token.isCancellationRequested) {
resolved = await this.configurationManager.resolveDebugConfigurationWithSubstitutedVariables(launch && launch.workspace ? launch.workspace.uri : undefined, unresolved.type, resolved, initCancellationToken.token);
}
} else {
resolved = resolvedByProviders;
}
}

if (!resolved) {
return c(undefined);
}

session.setConfiguration({ resolved, unresolved });
session.configuration.__restart = restartData;

try {
await this.launchOrAttachToSession(session, shouldFocus);
this._onDidNewSession.fire(session);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/debug/browser/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class DebugSession implements IDebugSession {
}

this.cancelAllRequests();
await this.raw.restart();
await this.raw.restart({ arguments: this.configuration });
}

async sendBreakpoints(modelUri: URI, breakpointsToSend: IBreakpoint[], sourceModified: boolean): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/debug/browser/rawDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ export class RawDebugSession implements IDisposable {
return Promise.reject(new Error('terminated not supported'));
}

restart(): Promise<DebugProtocol.RestartResponse | undefined> {
restart(args: DebugProtocol.RestartArguments): Promise<DebugProtocol.RestartResponse | undefined> {
if (this.capabilities.supportsRestartRequest) {
return this.send('restart', null);
return this.send('restart', args);
}
return Promise.reject(new Error('restart not supported'));
}
Expand Down

0 comments on commit 4430569

Please sign in to comment.