提交 81999809 编写于 作者: I isidor

debug: try to always create a launch.json as a last resort

fixes #19302
上级 ff8aa98b
......@@ -127,14 +127,18 @@ export class StartAction extends AbstractDebugAction {
}
const configuration = manager.getConfiguration(configName);
return manager.getStartSessionCommand(configuration ? configuration.type : undefined).then(command => {
if (command) {
return this.commandService.executeCommand(command, configuration || this.getDefaultConfiguration());
return manager.getStartSessionCommand(configuration ? configuration.type : undefined).then(commandAndType => {
if (commandAndType && commandAndType.command) {
return this.commandService.executeCommand(commandAndType.command, configuration || this.getDefaultConfiguration());
}
if (configName) {
return this.commandService.executeCommand('_workbench.startDebug', configName);
}
if (this.contextService.getWorkspace()) {
return manager.openConfigFile(false, commandAndType ? commandAndType.type : undefined);
}
});
}
......
......@@ -360,9 +360,9 @@ export interface IConfigurationManager {
getCompound(name: string): ICompound;
/**
* Opens the launch.json file
* Opens the launch.json file. Creates if it does not exist.
*/
openConfigFile(sideBySide: boolean): TPromise<IEditor>;
openConfigFile(sideBySide: boolean, type?: string): TPromise<IEditor>;
/**
* Returns true if breakpoints can be set for a given editor model. Depends on mode.
......@@ -374,7 +374,7 @@ export interface IConfigurationManager {
* If no type is specified will try to automatically pick an adapter by looking at
* the active editor language and matching it against the "languages" contribution of an adapter.
*/
getStartSessionCommand(type?: string): TPromise<string>;
getStartSessionCommand(type?: string): TPromise<{ command: string, type: string }>;
}
// Debug service interfaces
......
......@@ -342,12 +342,12 @@ export class ConfigurationManager implements debug.IConfigurationManager {
return this.configurationResolverService.resolveInteractiveVariables(result, adapter ? adapter.variables : null);
}
public openConfigFile(sideBySide: boolean): TPromise<IEditor> {
public openConfigFile(sideBySide: boolean, type?: string): TPromise<IEditor> {
const resource = uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '/.vscode/launch.json'));
let configFileCreated = false;
return this.fileService.resolveContent(resource).then(content => true, err =>
this.guessAdapter().then(adapter => adapter ? adapter.getInitialConfigurationContent() : undefined)
this.guessAdapter(type).then(adapter => adapter ? adapter.getInitialConfigurationContent() : undefined)
.then(content => {
if (!content) {
return false;
......@@ -375,10 +375,13 @@ export class ConfigurationManager implements debug.IConfigurationManager {
});
}
public getStartSessionCommand(type?: string): TPromise<string> {
public getStartSessionCommand(type?: string): TPromise<{ command: string, type: string }> {
return this.guessAdapter(type).then(adapter => {
if (adapter) {
return adapter.startSessionCommand;
return {
command: adapter.startSessionCommand,
type: adapter.type
};
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册