提交 559f6505 编写于 作者: I isidor

debug: set configuration properly when being passed by api

fixes #6806
fixes #6808
上级 f21b6d16
......@@ -500,10 +500,9 @@ export class DebugService implements debug.IDebugService {
return this.textFileService.saveAll() // make sure all dirty files are saved
.then(() => this.configurationService.loadConfiguration() // make sure configuration is up to date
.then(() => this.extensionService.onReady()
.then(() => this.configurationManager.setConfiguration((this.configurationManager.configurationName))
.then(() => this.configurationManager.setConfiguration(configuration || this.configurationManager.configurationName)
.then(() => {
this.configurationManager.resloveConfiguration(configuration);
configuration = configuration || this.configurationManager.configuration;
configuration = this.configurationManager.configuration;
if (!configuration) {
return this.configurationManager.openConfigFile(false).then(openend => {
if (openend) {
......
......@@ -228,33 +228,34 @@ export class ConfigurationManager implements debug.IConfigurationManager {
return this.adapters.filter(adapter => strings.equalsIgnoreCase(adapter.type, this.configuration.type)).pop();
}
public setConfiguration(name: string): TPromise<void> {
public setConfiguration(nameOrConfig: string|debug.IConfig): TPromise<void> {
return this.loadLaunchConfig().then(config => {
if (!config || !config.configurations) {
if (typeof nameOrConfig === 'string' && (!config || !config.configurations)) {
this.configuration = null;
return;
}
// if the configuration name is not set yet, take the first launch config (can happen if debug viewlet has not been opened yet).
const filtered = name ? config.configurations.filter(cfg => cfg.name === name) : [config.configurations[0]];
if (typeof nameOrConfig === 'string') {
// if the configuration name is not set yet, take the first launch config (can happen if debug viewlet has not been opened yet).
const filtered = nameOrConfig ? config.configurations.filter(cfg => cfg.name === nameOrConfig) : [config.configurations[0]];
this.configuration = filtered.length === 1 ? objects.deepClone(filtered[0]) : null;
if (config && this.configuration) {
this.configuration.debugServer = config.debugServer;
}
} else {
this.configuration = objects.deepClone(nameOrConfig);
}
// massage configuration attributes - append workspace path to relatvie paths, substitute variables in paths.
this.configuration = filtered.length === 1 ? objects.deepClone(filtered[0]) : null;
if (this.configuration) {
this.resloveConfiguration(this.configuration);
this.configuration.debugServer = config.debugServer;
if (this.configuration && this.systemVariables) {
Object.keys(this.configuration).forEach(key => {
this.configuration[key] = this.systemVariables.resolveAny(this.configuration[key]);
});
}
}).then(() => this._onDidConfigurationChange.fire(this.configurationName));
}
public resloveConfiguration(configuration: debug.IConfig) {
if (this.systemVariables && configuration) {
Object.keys(configuration).forEach(key => {
configuration[key] = this.systemVariables.resolveAny(configuration[key]);
});
}
}
public openConfigFile(sideBySide: boolean): TPromise<boolean> {
const resource = uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '/.vscode/launch.json'));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册