Mitigate issue with migrating Insiders to Prerelease (#8705)

This commit is contained in:
Colen Garoutte-Carson 2022-01-20 15:17:08 -08:00 коммит произвёл GitHub
Родитель 2d1f8e09ac
Коммит c694184fea
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 28 добавлений и 7 удалений

Просмотреть файл

@ -2749,7 +2749,7 @@ export class DefaultClient implements Client {
this.model.codeAnalysisTotal.Value = total;
}
private doneInitialCustomBrowseConfigurationCheck: Boolean = false;
private doneInitialCustomBrowseConfigurationCheck: boolean = false;
private onConfigurationsChanged(cppProperties: configs.CppProperties): void {
if (!cppProperties.Configurations) {

Просмотреть файл

@ -62,7 +62,7 @@ class Settings {
return result;
}
protected getWithUndefinedDefault<T>(section: string): T | undefined {
public getWithUndefinedDefault<T>(section: string): T | undefined {
const info: any = this.settings.inspect<T>(section);
if (info.workspaceFolderValue !== undefined) {
return info.workspaceFolderValue;

Просмотреть файл

@ -577,7 +577,7 @@ export function execChildProcess(process: string, workingDirectory?: string, cha
child_process.exec(process, { cwd: workingDirectory, maxBuffer: 500 * 1024 }, (error: Error | null, stdout: string, stderr: string) => {
if (channel) {
let message: string = "";
let err: Boolean = false;
let err: boolean = false;
if (stdout && stdout.length > 0) {
message += stdout;
}
@ -935,8 +935,8 @@ export function escapeForSquiggles(s: string): string {
// Replace all \<escape character> with \\<character>, except for \"
// Otherwise, the JSON.parse result will have the \<escape character> missing.
let newResults: string = "";
let lastWasBackslash: Boolean = false;
let lastBackslashWasEscaped: Boolean = false;
let lastWasBackslash: boolean = false;
let lastBackslashWasEscaped: boolean = false;
for (let i: number = 0; i < s.length; i++) {
if (s[i] === '\\') {
if (lastWasBackslash) {
@ -1258,7 +1258,7 @@ export function getCppToolsTargetPopulation(): TargetPopulation {
return TargetPopulation.Internal;
}
export function isVsCodeInsiders(): Boolean {
export function isVsCodeInsiders(): boolean {
return extensionPath.includes(".vscode-insiders") ||
extensionPath.includes(".vscode-server-insiders") ||
extensionPath.includes(".vscode-exploration") ||

Просмотреть файл

@ -145,14 +145,16 @@ function sendTelemetry(info: PlatformInformation): void {
}
export function UpdateInsidersAccess(): void {
let installPrerelease: boolean = false;
// 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")) {
installPrerelease = true;
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.
@ -160,4 +162,23 @@ export function UpdateInsidersAccess(): void {
migratedInsiders.Value = false;
}
}
// Mitigate an issue with VS Code not recognizing a programmatically installed VSIX as Prerelease.
// If using VS Code Insiders, and updateChannel is not explicitly set, default to Prerelease.
// Only do this once. If the user manually switches to Release, we don't want to switch them back to Prerelease again.
if (util.isVsCodeInsiders()) {
const insidersMitigationDone: PersistentState<boolean> = new PersistentState<boolean>("CPP.insidersMitigationDone", false);
if (!insidersMitigationDone.Value) {
if (vscode.workspace.getConfiguration("extensions", null).get<boolean>("autoUpdate")) {
if (settings.getWithUndefinedDefault<string>("updateChannel") === undefined) {
installPrerelease = true;
}
}
insidersMitigationDone.Value = true;
}
}
if (installPrerelease) {
vscode.commands.executeCommand("workbench.extensions.installExtension", "ms-vscode.cpptools", { installPreReleaseVersion: true });
}
}