Skip to content

Commit

Permalink
src/goLanguageServer: add gopls version to opt-out survey
Browse files Browse the repository at this point in the history
Change-Id: Iaa981cf22ff328143b961ddfb61035d31f9e15b2
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/303118
Trust: Rebecca Stambler <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
  • Loading branch information
stamblerre committed Mar 19, 2021
1 parent 73e7c36 commit d2bffd2
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function scheduleGoplsSuggestions() {
if (!usingGopls(cfg)) {
// This shouldn't happen, but if the user has a non-gopls language
// server enabled, we shouldn't prompt them to change.
if (cfg.serverName !== '') {
if (cfg.serverName !== '' && cfg.serverName !== 'gopls') {
return;
}
// Prompt the user to enable gopls and record what actions they took.
Expand All @@ -232,7 +232,6 @@ function scheduleGoplsSuggestions() {
}
maybePromptForGoplsSurvey();
};

setTimeout(update, 10 * timeMinute);
setTimeout(survey, 30 * timeMinute);
}
Expand Down Expand Up @@ -313,10 +312,18 @@ async function promptForGoplsOptOutSurvey(cfg: GoplsOptOutConfig, msg: string):
if (!s) {
return cfg;
}
let goplsVersion = await getLocalGoplsVersion(latestConfig);
if (!goplsVersion) {
goplsVersion = 'not found';
}
switch (s.title) {
case 'Yes':
cfg.prompt = false;
await vscode.env.openExternal(vscode.Uri.parse('https://forms.gle/hwC8CncV7Cyc2yBN6'));
await vscode.env.openExternal(
vscode.Uri.parse(
`https://docs.google.com/forms/d/e/1FAIpQLSdeqOas92JBD3Qkr-XyIiCuPeZvjmUuL07vu3WFNeaZZvrJDQ/viewform?entry.1049591455=${goplsVersion}&resourcekey=0-VmBGvZtiC8z9qytyA8ThnA`
)
);
break;
case 'No':
break;
Expand Down Expand Up @@ -446,7 +453,6 @@ export async function buildLanguageClient(cfg: BuildLanguageClientOption): Promi
if (isInPreviewMode()) {
documentSelector.push({ language: 'tmpl', scheme: 'file' }, { language: 'tmpl', scheme: 'untitled' });
}

const c = new LanguageClient(
'go', // id
cfg.serverName, // name e.g. gopls
Expand Down Expand Up @@ -935,10 +941,6 @@ export function buildLanguageServerConfig(goConfig: vscode.WorkspaceConfiguratio
env: toolExecutionEnvironment(),
checkForUpdates: getCheckForToolsUpdatesConfig(goConfig)
};
// Don't look for the path if the server is not enabled.
if (!cfg.enabled) {
return cfg;
}
const languageServerPath = getLanguageServerToolPath();
if (!languageServerPath) {
// Assume the getLanguageServerToolPath will show the relevant
Expand All @@ -949,6 +951,10 @@ 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 Expand Up @@ -1017,6 +1023,9 @@ export async function shouldUpdateLanguageServer(
if (tool.name !== 'gopls' || (!mustCheck && (cfg.checkForUpdates === 'off' || IsInCloudIDE))) {
return null;
}
if (!cfg.enabled) {
return null;
}

// First, run the "gopls version" command and parse its results.
// TODO(rstambler): Confirm that the gopls binary's modtime matches the
Expand Down

0 comments on commit d2bffd2

Please sign in to comment.