Skip to content

Commit 2882143

Browse files
committed
extension/src: skip tool existence check if replaced by gopls
When gopls is running, format tools it replaces are ineffective. This change prevents VS Code Go from prompting for their installation when gopls is active. For #3677 Change-Id: Ic1fabf0687b6c9b3687dbc59e2099859b90d2250 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/648415 kokoro-CI: kokoro <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Madeline Kalil <[email protected]>
1 parent 8dc2b5a commit 2882143

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

extension/src/goMain.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import { toggleVulncheckCommandFactory } from './goVulncheck';
7575
import { GoTaskProvider } from './goTaskProvider';
7676
import { setTelemetryEnvVars, telemetryReporter } from './goTelemetry';
7777
import { experiments } from './experimental';
78+
import { allToolsInformation } from './goToolsInformation';
7879

7980
const goCtx: GoExtensionContext = {};
8081

@@ -300,7 +301,16 @@ function addOnDidChangeConfigListeners(ctx: vscode.ExtensionContext) {
300301
}
301302

302303
if (e.affectsConfiguration('go.formatTool')) {
303-
checkToolExists(getFormatTool(updatedGoConfig));
304+
const tool = getFormatTool(updatedGoConfig);
305+
// When language server gopls is active (by default), existence
306+
// checks are skipped only for tools that gopls replaces. Other
307+
// tools are still checked.
308+
if (
309+
updatedGoConfig['useLanguageServer'] === false ||
310+
!new Set(['gofmt', 'goimports', 'goformat']).has(tool)
311+
) {
312+
checkToolExists(tool);
313+
}
304314
}
305315
if (e.affectsConfiguration('go.lintTool')) {
306316
checkToolExists(updatedGoConfig['lintTool']);

0 commit comments

Comments
 (0)