Skip to content

Commit

Permalink
Merge pull request #8669 from microsoft/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Colengms committed Jan 13, 2022
2 parents 7b175d4 + 75fc2a8 commit 88f0bbe
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 167 deletions.
6 changes: 3 additions & 3 deletions .github/actions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .github/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"@actions/github": "^2.1.1",
"axios": "^0.21.4"
},
"resolutions": {
"follow-redirects": "1.14.7"
},
"devDependencies": {
"eslint": "^8.1.0",
"typescript": "^3.8.3"
Expand Down
14 changes: 7 additions & 7 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4391,32 +4391,32 @@
"xml2js": "^0.4.19"
},
"dependencies": {
"comment-json": "^3.0.3",
"comment-json": "^4.1.1",
"editorconfig": "^0.15.3",
"escape-string-regexp": "^2.0.0",
"https-proxy-agent": "^2.2.4",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"mkdirp": "^0.5.5",
"plist": "^3.0.4",
"tmp": "^0.1.0",
"tmp": "^0.2.1",
"vscode-cpptools": "^5.0.0",
"vscode-extension-telemetry": "^0.1.7",
"vscode-extension-telemetry": "^0.4.4",
"vscode-languageclient": "^5.2.1",
"vscode-nls": "^4.1.1",
"vscode-tas-client": "^0.1.22",
"vscode-nls": "^5.0.0",
"vscode-tas-client": "^0.1.27",
"which": "^2.0.2",
"yauzl": "^2.10.0"
},
"resolutions": {
"**/mkdirp/minimist": "^0.2.1",
"follow-redirects": "1.14.7",
"ansi-regex": "^5.0.1",
"yargs-parser": "^15.0.1",
"y18n": "^5.0.5",
"hosted-git-info": "^3.0.8",
"browserslist": "^4.16.6",
"glob-parent": "^5.1.2",
"path-parse": "^1.0.7",
"axios": "^0.21.4",
"set-value": "^4.0.1"
}
}
6 changes: 3 additions & 3 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
}

Expand Down
54 changes: 15 additions & 39 deletions Extension/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,7 +77,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<CppToo
}
LanguageServer.activate();

HandleInsidersPrompt();
UpdateInsidersAccess();

return cppTools;
}
Expand Down Expand Up @@ -134,39 +129,20 @@ function sendTelemetry(info: PlatformInformation): void {
Telemetry.logDebuggerEvent("acquisition", telemetryProperties);
}

export function HandleInsidersPrompt(): void {
// Only display this prompt to users who have updateChannel configured for Insiders,
// and who are not already configured to receive pre-release extensions.

const targetPopulation: TargetPopulation = util.getCppToolsTargetPopulation();
// Skip the prompt if already using an insiders build of cpptools.
if (targetPopulation === TargetPopulation.Public) {
const settings: CppSettings = new CppSettings();
const displayedInsidersPrompt: PersistentState<boolean> = new PersistentState<boolean>("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<boolean> = new PersistentState<boolean>("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<boolean>("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;
}
}
}
Loading

0 comments on commit 88f0bbe

Please sign in to comment.