diff --git a/src/goImport.ts b/src/goImport.ts index 5d99b9f56..d9a2d0b36 100644 --- a/src/goImport.ts +++ b/src/goImport.ts @@ -13,7 +13,7 @@ import { promptForMissingTool } from './goInstallTools'; import path = require('path'); export function listPackages(excludeImportedPkgs: boolean = false): Thenable { - let importsPromise = excludeImportedPkgs && vscode.window.activeTextEditor ? getImports(vscode.window.activeTextEditor.document.fileName) : Promise.resolve([]); + let importsPromise = excludeImportedPkgs && vscode.window.activeTextEditor ? getImports(vscode.window.activeTextEditor.document) : Promise.resolve([]); let vendorSupportPromise = isVendorSupported(); let goPkgsPromise = new Promise((resolve, reject) => { cp.execFile(getBinPath('gopkgs'), [], (err, stdout, stderr) => { @@ -85,11 +85,11 @@ export function listPackages(excludeImportedPkgs: boolean = false): Thenable { - let options = { fileName: fileName, importsOnly: true }; +function getImports(document: vscode.TextDocument): Promise { + let options = { fileName: document.fileName, importsOnly: true, document }; return documentSymbols(options).then(symbols => { if (!symbols || !symbols[0] || !symbols[0].children) { return [];