Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Use cwd when running impl Fixes #1769
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jul 17, 2018
1 parent 3aced0e commit 18a313a
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/goImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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./]+)$/;
Expand All @@ -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 && (<any>err).code === 'ENOENT') {
promptForMissingTool('impl');
return;
Expand Down

0 comments on commit 18a313a

Please sign in to comment.