Skip to content

Commit

Permalink
Fixes microsoft#745 Implement startSessionCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Feb 5, 2017
1 parent 4eccd65 commit e7c8273
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"activationEvents": [
"onLanguage:go",
"onCommand:go.gopath",
"onCommand:go.tools.install"
"onCommand:go.tools.install",
"onCommand:go.debug.startSession"
],
"main": "./out/src/goMain",
"contributes": {
Expand Down Expand Up @@ -153,6 +154,7 @@
"languages": [
"go"
],
"startSessionCommand": "go.debug.startSession",
"initialConfigurations": [
{
"name": "Launch",
Expand Down
2 changes: 2 additions & 0 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class Delve {
connectClient(port, host);
return;
}
if (!env) env = {};

let dlv = getBinPathWithPreferredGopath('dlv', env['GOPATH']);

if (!existsSync(dlv)) {
Expand Down
13 changes: 13 additions & 0 deletions src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ export function activate(ctx: vscode.ExtensionContext): void {
goGenerateTests.toggleTestFile();
}));

ctx.subscriptions.push(vscode.commands.registerCommand('go.debug.startSession', config => {
if (!config.request) { // if 'request' is missing interpret this as a missing launch.json
config = Object.assign(config, {
'name': 'Launch',
'type': 'go',
'request': 'launch',
'mode': 'debug',
'program': '${workspaceRoot}'
});
}
vscode.commands.executeCommand('vscode.startDebug', config);
}));

vscode.languages.setLanguageConfiguration(GO_MODE.language, {
indentationRules: {
// ^(.*\*/)?\s*\}.*$
Expand Down

0 comments on commit e7c8273

Please sign in to comment.