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

Silent scan for kits to avoid breaking changes in kits definition #1211

Merged
merged 11 commits into from
May 13, 2020
Merged
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
USER_KITS_FILEPATH,
findCLCompilerPath,
effectiveKitEnvironment,
scanForKitsIfNeeded,
} from '@cmt/kit';
import {KitsController} from '@cmt/kitsController';
import * as logging from '@cmt/logging';
Expand Down Expand Up @@ -1106,6 +1107,9 @@ export async function activate(context: vscode.ExtensionContext) {
await vscode.window.showWarningMessage(localize('uninstall.old.cmaketools', 'Please uninstall any older versions of the CMake Tools extension. It is now published by Microsoft starting with version 1.2.0.'));
}

// Silent re-scan when detecting a breaking change in the kits definition.
await scanForKitsIfNeeded(context);

// Register a protocol handler to serve localized schemas
vscode.workspace.registerTextDocumentContentProvider('cmake-tools-schema', new SchemaProvider());
vscode.commands.executeCommand("setContext", "inCMakeProject", true);
Expand Down
12 changes: 12 additions & 0 deletions src/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,18 @@ export async function scanForKits(opt?: KitScanOptions) {
});
}

// Rescan if the kits versions (extension context state var versus value defined for this release) don't match.
export async function scanForKitsIfNeeded(context: vscode.ExtensionContext) : Promise<void> {
const kitsVersionSaved = context.workspaceState.get<number>('kitsVersionSaved');
andreeis marked this conversation as resolved.
Show resolved Hide resolved
const kitsVersionCurrent = 1;

// Scan also when there is no kits version saved in the state.
if (!kitsVersionSaved || kitsVersionSaved !== kitsVersionCurrent) {
await scanForKits();
context.workspaceState.update('kitsVersionSaved', kitsVersionCurrent);
}
}

/**
* Generates a string description of a kit. This is shown to the user.
* @param kit The kit to generate a description for
Expand Down