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

Commit

Permalink
Use byteoffset when calling gocode Fixes #1431
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jan 2, 2018
1 parent 265bbef commit 4b588af
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Binary file modified Go-latest.vsix
Binary file not shown.
2 changes: 1 addition & 1 deletion src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function activate(ctx: vscode.ExtensionContext): void {
"data": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
// sendTelemetryEvent('beta-testing', { version: '0.6.70', date: '12/08/2017' });
sendTelemetryEvent('beta-testing', { version: '0.6.71', date: '01/01/2018' });

let useLangServer = vscode.workspace.getConfiguration('go')['useLanguageServer'];
let langServerFlags: string[] = vscode.workspace.getConfiguration('go')['languageServerFlags'] || [];
Expand Down
6 changes: 3 additions & 3 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import vscode = require('vscode');
import cp = require('child_process');
import { getBinPath, parameters, parseFilePrelude, isPositionInString, goKeywords, getToolsEnvVars, guessPackageNameFromFile, goBuiltinTypes } from './util';
import { getBinPath, parameters, parseFilePrelude, isPositionInString, goKeywords, getToolsEnvVars, guessPackageNameFromFile, goBuiltinTypes, byteOffsetAt } from './util';
import { promptForMissingTool } from './goInstallTools';
import { getTextEditForAddImport } from './goImport';
import { getImportablePackages } from './goPackages';
Expand Down Expand Up @@ -71,7 +71,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
return resolve([]);
}

let offset = document.offsetAt(position);
let offset = byteOffsetAt(document, position);
let inputText = document.getText();
let includeUnimportedPkgs = autocompleteUnimportedPackages && !inString;

Expand Down Expand Up @@ -128,7 +128,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
let stderr = '';

// Spawn `gocode` process
let p = cp.spawn(gocode, ['-f=json', 'autocomplete', filename, 'c' + offset], { env });
let p = cp.spawn(gocode, ['-f=json', 'autocomplete', filename, '' + offset], { env });
p.stdout.on('data', data => stdout += data);
p.stderr.on('data', data => stderr += data);
p.on('error', err => {
Expand Down

0 comments on commit 4b588af

Please sign in to comment.