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

Commit

Permalink
fix workspaceModCache hit
Browse files Browse the repository at this point in the history
  • Loading branch information
sunliver committed Jan 11, 2019
1 parent ed66642 commit df67b14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/goDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ function definitionLocation_godef(input: GoDefinitionInput, token: vscode.Cancel
reject(e);
}
});
if (p.pid) {
p.stdin.end(input.document.getText());
}
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/goModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export function getModPath(fileuri: vscode.Uri): Promise<string> {
return Promise.resolve(hit);
}

workspaceModCache.forEach((v, k) => {
for (let k of Array.from(workspaceModCache.keys())) {
if (folderPath.startsWith(k)) {
folderModCache.set(folderPath, k);
return Promise.resolve(k);
}
});
}

return getGoVersion().then(value => {
if (value && (value.major !== 1 || value.minor < 11)) {
Expand All @@ -40,9 +40,9 @@ export function getModPath(fileuri: vscode.Uri): Promise<string> {
if (!goExecutable) {
return Promise.reject(new Error('Cannot find "go" binary. Update PATH or GOROOT appropriately.'));
}
cp.execFile(goExecutable, ['env', 'GOMOD'], { cwd: folderPath, env: getToolsEnvVars() }, (err, stdout) => {
cp.execFile(goExecutable, ['list', '-m', '-f', '{{.GoMod}}'], { cwd: folderPath, env: getToolsEnvVars() }, (err, stdout) => {
if (err) {
console.warn(`Error when running go env GOMOD: ${err}`);
console.warn(`Error when running go list -m -f {{.GoMod}}: ${err}`);
resolve('');
}
let [goMod] = stdout.split('\n');
Expand Down

0 comments on commit df67b14

Please sign in to comment.