From 58817b85b1609c3d939f9f6b5429817fafe93c69 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Mon, 21 Jan 2019 18:23:12 -0800 Subject: [PATCH] Infer gopath correctly when no folder is opened --- src/util.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util.ts b/src/util.ts index c8de20829..82dcf5cbb 100644 --- a/src/util.ts +++ b/src/util.ts @@ -417,9 +417,11 @@ export function substituteEnv(input: string): string { export function getCurrentGoPath(workspaceUri?: vscode.Uri): string { let currentFilePath: string; - if (vscode.window.activeTextEditor && vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri)) { - workspaceUri = workspaceUri || vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri; + if (vscode.window.activeTextEditor) { currentFilePath = vscode.window.activeTextEditor.document.uri.fsPath; + if (!workspaceUri && vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri)) { + workspaceUri = vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri; + } } const config = vscode.workspace.getConfiguration('go', workspaceUri); let currentRoot = workspaceUri ? workspaceUri.fsPath : vscode.workspace.rootPath;