Skip to content

Commit

Permalink
[release] src/language/goLanguageServer: do not require gopls when la…
Browse files Browse the repository at this point in the history
…nguage 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>
(cherry picked from commit 4dd972e)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/414459
  • Loading branch information
hyangah committed Jun 29, 2022
1 parent 0a0827e commit b3330f9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/language/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,12 @@ export function buildLanguageServerConfig(goConfig: vscode.WorkspaceConfiguratio
env: toolExecutionEnvironment(),
checkForUpdates: getCheckForToolsUpdatesConfig(goConfig)
};
// user has opted out of using the language server.
if (!cfg.enabled) {
return cfg;
}

// locate the configured language server tool.
const languageServerPath = getLanguageServerToolPath();
if (!languageServerPath) {
// Assume the getLanguageServerToolPath will show the relevant
Expand All @@ -793,10 +799,6 @@ export function buildLanguageServerConfig(goConfig: vscode.WorkspaceConfiguratio
cfg.path = languageServerPath;
cfg.serverName = getToolFromToolPath(cfg.path) ?? '';

if (!cfg.enabled) {
return cfg;
}

// Get the mtime of the language server binary so that we always pick up
// the right version.
const stats = fs.statSync(languageServerPath);
Expand Down

0 comments on commit b3330f9

Please sign in to comment.