sync: merge microsoft/vscode-go@765f96d into master

Change-Id: Ic43348753d9e53a26e9d8e45ad9f69ee16522a14
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ba09a3..f93a946 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,4 +2,3 @@
 * Set the extension name for VS Code Go Nightly(`go-nightly`).
 * Pick up the pre-release version of `gopls` if available.
 * Disabled the telemetry report for VS Code Go.
-* Sync upstream@eae5825
diff --git a/src/goMain.ts b/src/goMain.ts
index 4de4089..3d58fe2 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -48,7 +48,14 @@
 import { testAtCursor, testCurrentFile, testCurrentPackage, testPrevious, testWorkspace } from './goTest';
 import { getConfiguredTools } from './goTools';
 import { vetCode } from './goVet';
-import { getFromGlobalState, setGlobalState, updateGlobalState } from './stateUtils';
+import {
+	getFromGlobalState,
+	getFromWorkspaceState,
+	setGlobalState,
+	setWorkspaceState,
+	updateGlobalState,
+	updateWorkspaceState
+} from './stateUtils';
 import { disposeTelemetryReporter, sendTelemetryEventForConfig } from './telemetry';
 import { cancelRunningTests, showTestOutput } from './testUtils';
 import {
@@ -71,6 +78,7 @@
 
 export function activate(ctx: vscode.ExtensionContext): void {
 	setGlobalState(ctx.globalState);
+	setWorkspaceState(ctx.workspaceState);
 
 	updateGoPathGoRootFromConfig().then(async () => {
 		const updateToolsCmdText = 'Update tools';
@@ -510,9 +518,12 @@
 				vscode.window.showErrorMessage('Cannot apply coverage profile when no Go file is open.');
 				return;
 			}
+			const lastCoverProfilePathKey = 'lastCoverProfilePathKey';
+			const lastCoverProfilePath = getFromWorkspaceState(lastCoverProfilePathKey, '');
 			vscode.window
 				.showInputBox({
-					prompt: 'Enter the path to the coverage profile for current package'
+					prompt: 'Enter the path to the coverage profile for current package',
+					value: lastCoverProfilePath,
 				})
 				.then((coverProfilePath) => {
 					if (!coverProfilePath) {
@@ -522,6 +533,9 @@
 						vscode.window.showErrorMessage(`Cannot find the file ${coverProfilePath}`);
 						return;
 					}
+					if (coverProfilePath !== lastCoverProfilePath) {
+						updateWorkspaceState(lastCoverProfilePathKey, coverProfilePath);
+					}
 					applyCodeCoverageToAllEditors(
 						coverProfilePath,
 						path.dirname(vscode.window.activeTextEditor.document.fileName)
diff --git a/src/stateUtils.ts b/src/stateUtils.ts
index 35983c5..067cd44 100644
--- a/src/stateUtils.ts
+++ b/src/stateUtils.ts
@@ -6,6 +6,7 @@
 import vscode = require('vscode');
 
 let globalState: vscode.Memento;
+let workspaceState: vscode.Memento;
 
 export function getFromGlobalState(key: string, defaultValue?: any) {
 	if (!globalState) {
@@ -24,3 +25,21 @@
 export function setGlobalState(state: vscode.Memento) {
 	globalState = state;
 }
+
+export function getFromWorkspaceState(key: string, defaultValue?: any) {
+	if (!workspaceState) {
+		return defaultValue;
+	}
+	return workspaceState.get(key, defaultValue);
+}
+
+export function updateWorkspaceState(key: string, value: any) {
+	if (!workspaceState) {
+		return;
+	}
+	return workspaceState.update(key, value);
+}
+
+export function setWorkspaceState(state: vscode.Memento) {
+	workspaceState = state;
+}
diff --git a/src/testUtils.ts b/src/testUtils.ts
index 533e461..1b3851b 100644
--- a/src/testUtils.ts
+++ b/src/testUtils.ts
@@ -325,21 +325,23 @@
 
 				// 1=ok/FAIL, 2=package, 3=time/(cached)
 				const packageResultLineRE = /^(ok|FAIL)[ \t]+(.+?)[ \t]+([0-9\.]+s|\(cached\))/;
+				const lineWithErrorRE = /^(\t|\s\s\s\s)\S/;
 				const testResultLines: string[] = [];
 
 				const processTestResultLine = (line: string) => {
-					if (!testconfig.includeSubDirectories) {
-						outputChannel.appendLine(expandFilePathInOutput(line, testconfig.dir));
-						return;
-					}
 					testResultLines.push(line);
 					const result = line.match(packageResultLineRE);
 					if (result && (pkgMap.has(result[2]) || currentGoWorkspace)) {
+						const hasTestFailed = line.startsWith('FAIL');
 						const packageNameArr = result[2].split('/');
 						const baseDir = pkgMap.get(result[2]) || path.join(currentGoWorkspace, ...packageNameArr);
-						testResultLines.forEach((testResultLine) =>
-							outputChannel.appendLine(expandFilePathInOutput(testResultLine, baseDir))
-						);
+						testResultLines.forEach((testResultLine) => {
+							if (hasTestFailed && lineWithErrorRE.test(testResultLine)) {
+								outputChannel.appendLine(expandFilePathInOutput(testResultLine, baseDir));
+							} else {
+								outputChannel.appendLine(testResultLine);
+							}
+						});
 						testResultLines.splice(0);
 					}
 				};