From 18a313a2b0c2b48dd043c5561c1c3d546cefec8c Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Tue, 17 Jul 2018 16:08:28 -0700 Subject: [PATCH] Use cwd when running impl Fixes #1769 --- src/goImpl.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/goImpl.ts b/src/goImpl.ts index a5bbab6be..7313e8c7e 100644 --- a/src/goImpl.ts +++ b/src/goImpl.ts @@ -9,11 +9,7 @@ import vscode = require('vscode'); import cp = require('child_process'); import { getBinPath, getToolsEnvVars } from './util'; import { promptForMissingTool } from './goInstallTools'; - -interface GoImplInput { - receiver: string; - interface: string; -} +import { dirname } from 'path'; // Supports only passing interface, see TODO in implCursor to finish const inputRegex = /^(\w+\ \*?\w+\ )?([\w./]+)$/; @@ -37,18 +33,13 @@ export function implCursor() { // if matches[1] is undefined then detect receiver type // take first character and use as receiver name - let input: GoImplInput = { - receiver: matches[1], - interface: matches[2] - }; - - runGoImpl(input, cursor.start); + runGoImpl([matches[1], matches[2]], cursor.start); }); } -function runGoImpl(input: GoImplInput, insertPos: vscode.Position) { +function runGoImpl(args: string[], insertPos: vscode.Position) { let goimpl = getBinPath('impl'); - let p = cp.execFile(goimpl, [input.receiver, input.interface], {env: getToolsEnvVars()}, (err, stdout, stderr) => { + let p = cp.execFile(goimpl, args, { env: getToolsEnvVars(), cwd: dirname(vscode.window.activeTextEditor.document.fileName) }, (err, stdout, stderr) => { if (err && (err).code === 'ENOENT') { promptForMissingTool('impl'); return;