Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Merged
Changes from all 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
12 changes: 11 additions & 1 deletion src/zigSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async function findClosestSatisfyingZigVersion(
// We can't just return `version` because `0.12.0` should return `0.12.1`.
const availableVersions = (await getVersions()).map((item) => item.version);
const selectedVersion = semver.maxSatisfying(availableVersions, `^${version.toString()}`);
await context.globalState.update(cacheKey, selectedVersion ?? undefined);
await context.globalState.update(cacheKey, selectedVersion ? selectedVersion.raw : undefined);
return selectedVersion ?? version;
} catch {
const selectedVersion = context.globalState.get<string | null>(cacheKey, null);
Expand Down Expand Up @@ -597,6 +597,16 @@ export async function setupZig(context: vscode.ExtensionContext) {
await workspaceConfigUpdateNoThrow(zigConfig, "initialSetupDone", undefined, true);

await context.workspaceState.update("zig-version", undefined);

// Remove incorrect values in the global state that have been added by
// an older version of the extension.
for (const key of context.globalState.keys()) {
if (!key.startsWith("zig-satisfying-version-")) continue;
const value = context.globalState.get(key);
if (value !== undefined && typeof value !== "string") {
await context.globalState.update(key, undefined);
}
}
}

/// Workaround https://github.com/ziglang/zig/issues/21905
Expand Down