Skip to content

Commit

Permalink
Use built-in flag for gocode
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jul 16, 2018
1 parent 2f63b20 commit 0f40521
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Binary file modified Go-latest.vsix
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Go",
"version": "0.6.85-beta.1",
"version": "0.6.85-beta.3",
"publisher": "ms-vscode",
"description": "Rich Go language support for Visual Studio Code",
"author": {
Expand Down
12 changes: 10 additions & 2 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import vscode = require('vscode');
import cp = require('child_process');
import { getBinPath, getParametersAndReturnType, parseFilePrelude, isPositionInString, goKeywords, getToolsEnvVars, guessPackageNameFromFile, goBuiltinTypes, byteOffsetAt } from './util';
import { promptForMissingTool } from './goInstallTools';
import { promptForMissingTool, promptForUpdatingTool } from './goInstallTools';
import { getTextEditForAddImport } from './goImport';
import { getImportablePackages } from './goPackages';

Expand Down Expand Up @@ -152,8 +152,13 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
let stdout = '';
let stderr = '';

let goCodeFlags = ['-f=json'];
if (!this.setGocodeOptions) {
goCodeFlags.push('-builtin');
}

// Spawn `gocode` process
let p = cp.spawn(gocode, ['-f=json', 'autocomplete', filename, '' + offset], { env });
let p = cp.spawn(gocode, [...goCodeFlags, 'autocomplete', filename, '' + offset], { env });
p.stdout.on('data', data => stdout += data);
p.stderr.on('data', data => stderr += data);
p.on('error', err => {
Expand All @@ -170,6 +175,9 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
vscode.window.showErrorMessage('Auto-completion feature failed as an older gocode process is still running. Please kill the running process for gocode and try again.');
this.killMsgShown = true;
}
if (stderr.startsWith('flag provided but not defined:')) {
promptForUpdatingTool('gocode');
}
return reject();
}
let results = <[number, GoCodeSuggestion[]]>JSON.parse(stdout.toString());
Expand Down

0 comments on commit 0f40521

Please sign in to comment.