diff --git a/src/goDeclaration.ts b/src/goDeclaration.ts index ede89b0da..667c78e5d 100644 --- a/src/goDeclaration.ts +++ b/src/goDeclaration.ts @@ -79,7 +79,7 @@ export function adjustWordPosition(document: vscode.TextDocument, position: vsco } const godefImportDefinitionRegex = /^import \(.* ".*"\)$/; -function definitionLocation_godef(input: GoDefinitionInput, token: vscode.CancellationToken): Promise { +function definitionLocation_godef(input: GoDefinitionInput, token: vscode.CancellationToken, useReceivers: boolean = true): Promise { let godefTool = 'godef'; let godefPath = getBinPath(godefTool); if (!path.isAbsolute(godefPath)) { @@ -95,7 +95,11 @@ function definitionLocation_godef(input: GoDefinitionInput, token: vscode.Cancel return new Promise((resolve, reject) => { // Spawn `godef` process - p = cp.execFile(godefPath, ['-t', '-r', '-i', '-f', input.document.fileName, '-o', offset.toString()], { env, cwd }, (err, stdout, stderr) => { + const args = ['-t', '-i', '-f', input.document.fileName, '-o', offset.toString()]; + if (useReceivers) { + args.push('-r'); + } + p = cp.execFile(godefPath, args, { env, cwd }, (err, stdout, stderr) => { try { if (err && (err).code === 'ENOENT') { return reject(missingToolMsg + godefTool); @@ -104,7 +108,8 @@ function definitionLocation_godef(input: GoDefinitionInput, token: vscode.Cancel if (stderr.indexOf('flag provided but not defined: -r') !== -1) { promptForUpdatingTool('godef'); } - return reject(err.message || stderr); + p = null; + return definitionLocation_godef(input, token, false).then(resolve, reject); } let result = stdout.toString(); let lines = result.split('\n'); @@ -173,7 +178,7 @@ function definitionLocation_gogetdoc(input: GoDefinitionInput, token: vscode.Can } if (stderr && stderr.startsWith('flag provided but not defined: -tags')) { p = null; - return definitionLocation_gogetdoc(input, token, false); + return definitionLocation_gogetdoc(input, token, false).then(resolve, reject); } if (err) { if (input.isMod