From 75fc2a842cdb8e7979e1a8727f0a45d7d7bc1513 Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson <49173979+Colengms@users.noreply.github.com> Date: Thu, 13 Jan 2022 13:25:50 -0800 Subject: [PATCH] Move existing insiders to new mechanism without prompting (#8665) --- Extension/src/LanguageServer/extension.ts | 6 +-- Extension/src/main.ts | 54 +++++++---------------- 2 files changed, 18 insertions(+), 42 deletions(-) diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index 604b6dde6e..98b6ed4e54 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -24,7 +24,7 @@ import * as yauzl from 'yauzl'; import { Readable } from 'stream'; import * as nls from 'vscode-nls'; import { CppBuildTaskProvider } from './cppBuildTaskProvider'; -import { HandleInsidersPrompt } from '../main'; +import { UpdateInsidersAccess } from '../main'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -299,8 +299,8 @@ function onDidChangeSettings(event: vscode.ConfigurationChangeEvent): void { }); const newUpdateChannel: string = changedActiveClientSettings['updateChannel']; - if (newUpdateChannel) { - HandleInsidersPrompt(); + if (newUpdateChannel || event.affectsConfiguration("extensions.autoUpdate")) { + UpdateInsidersAccess(); } } diff --git a/Extension/src/main.ts b/Extension/src/main.ts index c269ed4eb2..86a6c85cc5 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -11,17 +11,12 @@ import * as path from 'path'; import * as Telemetry from './telemetry'; import * as util from './common'; import * as vscode from 'vscode'; -import * as nls from 'vscode-nls'; import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools'; import { PlatformInformation } from './platform'; import { CppTools1 } from './cppTools1'; import { CppSettings } from './LanguageServer/settings'; import { PersistentState } from './LanguageServer/persistentState'; -import { TargetPopulation } from 'vscode-tas-client'; - -nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); const cppTools: CppTools1 = new CppTools1(); let languageServiceDisabled: boolean = false; @@ -82,7 +77,7 @@ export async function activate(context: vscode.ExtensionContext): Promise = new PersistentState("CPP.displayedInsidersPrompt", false); - // Skip the prompt if updateChannel was not set to Insiders. - if (settings.updateChannel === "Insiders") { - if (!displayedInsidersPrompt.Value) { - displayedInsidersPrompt.Value = true; - const message: string = localize('updateChannel.changed', "The `C_Cpp.updateChannel` setting is deprecated. Do you want to enable install of pre-releases of the C/C++ extension via the Marketplace?"); - const yes: string = localize("yes.button", "Yes"); - const no: string = localize("no.button", "No"); - vscode.window.showInformationMessage(message, yes, no).then((selection) => { - switch (selection) { - case yes: - vscode.commands.executeCommand("workbench.extensions.installExtension", "ms-vscode.cpptools", { installPreReleaseVersion: true }); - break; - case no: - break; - default: - break; - } - }); - } - } else { - // Reset persistent value, so we prompt again if they switch to "Insiders" again. - if (displayedInsidersPrompt.Value) { - displayedInsidersPrompt.Value = false; - } +export function UpdateInsidersAccess(): void { + // Only move them to the new prerelease mechanism if using updateChannel of Insiders. + const settings: CppSettings = new CppSettings(); + const migratedInsiders: PersistentState = new PersistentState("CPP.migratedInsiders", false); + if (settings.updateChannel === "Insiders") { + // Don't do anything while the user has autoUpdate disabled, so we do not cause the extension to be updated. + if (!migratedInsiders.Value && vscode.workspace.getConfiguration("extensions", null).get("autoUpdate")) { + migratedInsiders.Value = true; + vscode.commands.executeCommand("workbench.extensions.installExtension", "ms-vscode.cpptools", { installPreReleaseVersion: true }); + } + } else { + // Reset persistent value, so we register again if they switch to "Insiders" again. + if (migratedInsiders.Value) { + migratedInsiders.Value = false; } } }