Avoid multiple entries. (#44)
This commit is contained in:
parent
077458186c
commit
f7f5cf94ce
|
@ -5,8 +5,15 @@ import * as path from "path";
|
|||
import * as vscode from "vscode";
|
||||
import * as commands from "./commands";
|
||||
|
||||
const status: any = {};
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.registerCommand(commands.JAVA_START_DEBUGSESSION, async (config) => {
|
||||
|
||||
if (!status.debugging) {
|
||||
status.debugging = "startDebugSession";
|
||||
|
||||
try {
|
||||
if (Object.keys(config).length === 0) { // No launch.json in current workspace.
|
||||
const ans = await vscode.window.showInformationMessage(
|
||||
"\"launch.json\" is needed to start the debugger. Do you want to create it now?", "Yes", "No");
|
||||
|
@ -32,20 +39,27 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
}
|
||||
} else {
|
||||
const ans = await vscode.window.showErrorMessage(
|
||||
// tslint:disable-next-line:max-line-length
|
||||
"Request type \"" + config.request + "\" is not supported. Only \"launch\" and \"attach\" are supported.", "Open launch.json");
|
||||
if (ans === "Open launch.json") {
|
||||
vscode.commands.executeCommand(commands.VSCODE_ADD_DEBUGCONFIGURATION);
|
||||
await vscode.commands.executeCommand(commands.VSCODE_ADD_DEBUGCONFIGURATION);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const debugServerPort = await startDebugSession();
|
||||
if (debugServerPort) {
|
||||
config.debugServer = debugServerPort;
|
||||
vscode.commands.executeCommand(commands.VSCODE_STARTDEBUG, config);
|
||||
await vscode.commands.executeCommand(commands.VSCODE_STARTDEBUG, config);
|
||||
} else {
|
||||
// Information for diagnostic:
|
||||
console.log("Cannot find a port for debugging session");
|
||||
}
|
||||
} catch (ex) {
|
||||
|
||||
} finally {
|
||||
delete status.debugging;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue