Skip to content

Commit 4dd972e

Browse files
committed
src/language/goLanguageServer: do not require gopls when language server is disabled
This fixes a bug that made the extension to look up the path to the gopls binary when go.useLanguageServer is false. During the lookup, if the gopls wasn't available, getLanguageServerToolPath eventually triggerred the missing tool prompt and that was not appropriate. Return from buildLanguageServerConfig early if we don't need the language server. Updates #2300 Change-Id: I7572244350f953c8ce874086f4f5cbb45a7301af Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/414456 Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Suzy Mueller <suzmue@golang.org> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: kokoro <noreply+kokoro@google.com>
1 parent ee683d7 commit 4dd972e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/language/goLanguageServer.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,12 @@ export function buildLanguageServerConfig(goConfig: vscode.WorkspaceConfiguratio
798798
env: toolExecutionEnvironment(),
799799
checkForUpdates: getCheckForToolsUpdatesConfig(goConfig)
800800
};
801+
// user has opted out of using the language server.
802+
if (!cfg.enabled) {
803+
return cfg;
804+
}
805+
806+
// locate the configured language server tool.
801807
const languageServerPath = getLanguageServerToolPath();
802808
if (!languageServerPath) {
803809
// Assume the getLanguageServerToolPath will show the relevant
@@ -808,10 +814,6 @@ export function buildLanguageServerConfig(goConfig: vscode.WorkspaceConfiguratio
808814
cfg.path = languageServerPath;
809815
cfg.serverName = getToolFromToolPath(cfg.path) ?? '';
810816

811-
if (!cfg.enabled) {
812-
return cfg;
813-
}
814-
815817
// Get the mtime of the language server binary so that we always pick up
816818
// the right version.
817819
const stats = fs.statSync(languageServerPath);

0 commit comments

Comments
 (0)