Skip to content

Commit 75fc2a8

Browse files
authored
Move existing insiders to new mechanism without prompting (#8665)
1 parent c0ff0ef commit 75fc2a8

File tree

2 files changed

+18
-42
lines changed

2 files changed

+18
-42
lines changed

Extension/src/LanguageServer/extension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import * as yauzl from 'yauzl';
2424
import { Readable } from 'stream';
2525
import * as nls from 'vscode-nls';
2626
import { CppBuildTaskProvider } from './cppBuildTaskProvider';
27-
import { HandleInsidersPrompt } from '../main';
27+
import { UpdateInsidersAccess } from '../main';
2828

2929
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
3030
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
@@ -299,8 +299,8 @@ function onDidChangeSettings(event: vscode.ConfigurationChangeEvent): void {
299299
});
300300

301301
const newUpdateChannel: string = changedActiveClientSettings['updateChannel'];
302-
if (newUpdateChannel) {
303-
HandleInsidersPrompt();
302+
if (newUpdateChannel || event.affectsConfiguration("extensions.autoUpdate")) {
303+
UpdateInsidersAccess();
304304
}
305305
}
306306

Extension/src/main.ts

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@ import * as path from 'path';
1111
import * as Telemetry from './telemetry';
1212
import * as util from './common';
1313
import * as vscode from 'vscode';
14-
import * as nls from 'vscode-nls';
1514

1615
import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools';
1716
import { PlatformInformation } from './platform';
1817
import { CppTools1 } from './cppTools1';
1918
import { CppSettings } from './LanguageServer/settings';
2019
import { PersistentState } from './LanguageServer/persistentState';
21-
import { TargetPopulation } from 'vscode-tas-client';
22-
23-
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
24-
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
2520

2621
const cppTools: CppTools1 = new CppTools1();
2722
let languageServiceDisabled: boolean = false;
@@ -82,7 +77,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<CppToo
8277
}
8378
LanguageServer.activate();
8479

85-
HandleInsidersPrompt();
80+
UpdateInsidersAccess();
8681

8782
return cppTools;
8883
}
@@ -134,39 +129,20 @@ function sendTelemetry(info: PlatformInformation): void {
134129
Telemetry.logDebuggerEvent("acquisition", telemetryProperties);
135130
}
136131

137-
export function HandleInsidersPrompt(): void {
138-
// Only display this prompt to users who have updateChannel configured for Insiders,
139-
// and who are not already configured to receive pre-release extensions.
140-
141-
const targetPopulation: TargetPopulation = util.getCppToolsTargetPopulation();
142-
// Skip the prompt if already using an insiders build of cpptools.
143-
if (targetPopulation === TargetPopulation.Public) {
144-
const settings: CppSettings = new CppSettings();
145-
const displayedInsidersPrompt: PersistentState<boolean> = new PersistentState<boolean>("CPP.displayedInsidersPrompt", false);
146-
// Skip the prompt if updateChannel was not set to Insiders.
147-
if (settings.updateChannel === "Insiders") {
148-
if (!displayedInsidersPrompt.Value) {
149-
displayedInsidersPrompt.Value = true;
150-
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?");
151-
const yes: string = localize("yes.button", "Yes");
152-
const no: string = localize("no.button", "No");
153-
vscode.window.showInformationMessage(message, yes, no).then((selection) => {
154-
switch (selection) {
155-
case yes:
156-
vscode.commands.executeCommand("workbench.extensions.installExtension", "ms-vscode.cpptools", { installPreReleaseVersion: true });
157-
break;
158-
case no:
159-
break;
160-
default:
161-
break;
162-
}
163-
});
164-
}
165-
} else {
166-
// Reset persistent value, so we prompt again if they switch to "Insiders" again.
167-
if (displayedInsidersPrompt.Value) {
168-
displayedInsidersPrompt.Value = false;
169-
}
132+
export function UpdateInsidersAccess(): void {
133+
// Only move them to the new prerelease mechanism if using updateChannel of Insiders.
134+
const settings: CppSettings = new CppSettings();
135+
const migratedInsiders: PersistentState<boolean> = new PersistentState<boolean>("CPP.migratedInsiders", false);
136+
if (settings.updateChannel === "Insiders") {
137+
// Don't do anything while the user has autoUpdate disabled, so we do not cause the extension to be updated.
138+
if (!migratedInsiders.Value && vscode.workspace.getConfiguration("extensions", null).get<boolean>("autoUpdate")) {
139+
migratedInsiders.Value = true;
140+
vscode.commands.executeCommand("workbench.extensions.installExtension", "ms-vscode.cpptools", { installPreReleaseVersion: true });
141+
}
142+
} else {
143+
// Reset persistent value, so we register again if they switch to "Insiders" again.
144+
if (migratedInsiders.Value) {
145+
migratedInsiders.Value = false;
170146
}
171147
}
172148
}

0 commit comments

Comments
 (0)