Skip to content

Commit e7c8273

Browse files
committed
Fixes microsoft#745 Implement startSessionCommand
1 parent 4eccd65 commit e7c8273

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"activationEvents": [
5757
"onLanguage:go",
5858
"onCommand:go.gopath",
59-
"onCommand:go.tools.install"
59+
"onCommand:go.tools.install",
60+
"onCommand:go.debug.startSession"
6061
],
6162
"main": "./out/src/goMain",
6263
"contributes": {
@@ -153,6 +154,7 @@
153154
"languages": [
154155
"go"
155156
],
157+
"startSessionCommand": "go.debug.startSession",
156158
"initialConfigurations": [
157159
{
158160
"name": "Launch",

src/debugAdapter/goDebug.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ class Delve {
187187
connectClient(port, host);
188188
return;
189189
}
190+
if (!env) env = {};
191+
190192
let dlv = getBinPathWithPreferredGopath('dlv', env['GOPATH']);
191193

192194
if (!existsSync(dlv)) {

src/goMain.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ export function activate(ctx: vscode.ExtensionContext): void {
156156
goGenerateTests.toggleTestFile();
157157
}));
158158

159+
ctx.subscriptions.push(vscode.commands.registerCommand('go.debug.startSession', config => {
160+
if (!config.request) { // if 'request' is missing interpret this as a missing launch.json
161+
config = Object.assign(config, {
162+
'name': 'Launch',
163+
'type': 'go',
164+
'request': 'launch',
165+
'mode': 'debug',
166+
'program': '${workspaceRoot}'
167+
});
168+
}
169+
vscode.commands.executeCommand('vscode.startDebug', config);
170+
}));
171+
159172
vscode.languages.setLanguageConfiguration(GO_MODE.language, {
160173
indentationRules: {
161174
// ^(.*\*/)?\s*\}.*$

0 commit comments

Comments
 (0)