Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent language service activation for macOS older than 10.12 #9328

Merged
merged 4 commits into from
May 20, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 36 additions & 18 deletions Extension/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,43 @@ export async function activate(context: vscode.ExtensionContext): Promise<CppToo
UpdateInsidersAccess();

const settings: CppSettings = new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined);
if (settings.intelliSenseEngine === "Disabled") {
languageServiceDisabled = true;
let isOldMacOs: boolean = false;
if (info.platform === 'darwin') {
const releaseParts: string[] = os.release().split(".");
if (releaseParts.length >= 1) {
isOldMacOs = parseInt(releaseParts[0]) < 16;
}
}
let currentIntelliSenseEngineValue: string | undefined = settings.intelliSenseEngine;
disposables.push(vscode.workspace.onDidChangeConfiguration(() => {
const settings: CppSettings = new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined);
if (!reloadMessageShown && settings.intelliSenseEngine !== currentIntelliSenseEngineValue) {
if (currentIntelliSenseEngineValue === "Disabled") {
// If switching from disabled to enabled, we can continue activation.
currentIntelliSenseEngineValue = settings.intelliSenseEngine;
languageServiceDisabled = false;
LanguageServer.activate();
} else {
// We can't deactivate or change engines on the fly, so prompt for window reload.
reloadMessageShown = true;
util.promptForReloadWindowDueToSettingsChange();
}

// Read the setting and determine whether we should activate the language server prior to installing callbacks,
// to ensure there is no potential race condition. LanguageServer.activate() is called near the end of this
// function, to allow any further setup to occur here, prior to activation.
const shouldActivateLanguageServer: boolean = (settings.intelliSenseEngine !== "Disabled" && !isOldMacOs);

if (isOldMacOs) {
languageServiceDisabled = true;
vscode.window.showErrorMessage(localize("macos.version.deprecated", "Versions of the C/C++ extension more recent than {0} require at least macOS version {1}.", "1.9.8", "10.12"));
} else {
if (settings.intelliSenseEngine === "Disabled") {
languageServiceDisabled = true;
}
}));
let currentIntelliSenseEngineValue: string | undefined = settings.intelliSenseEngine;
disposables.push(vscode.workspace.onDidChangeConfiguration(() => {
const settings: CppSettings = new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined);
if (!reloadMessageShown && settings.intelliSenseEngine !== currentIntelliSenseEngineValue) {
if (currentIntelliSenseEngineValue === "Disabled") {
// If switching from disabled to enabled, we can continue activation.
currentIntelliSenseEngineValue = settings.intelliSenseEngine;
languageServiceDisabled = false;
LanguageServer.activate();
} else {
// We can't deactivate or change engines on the fly, so prompt for window reload.
reloadMessageShown = true;
util.promptForReloadWindowDueToSettingsChange();
}
}
}));
}

if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) {
for (let i: number = 0; i < vscode.workspace.workspaceFolders.length; ++i) {
Expand Down Expand Up @@ -114,7 +132,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<CppToo
}
});

if (settings.intelliSenseEngine !== "Disabled") {
if (shouldActivateLanguageServer) {
await LanguageServer.activate();
}

Expand Down