@@ -85,7 +85,7 @@ async function findClosestSatisfyingZigVersion(
8585 // We can't just return `version` because `0.12.0` should return `0.12.1`.
8686 const availableVersions = ( await getVersions ( ) ) . map ( ( item ) => item . version ) ;
8787 const selectedVersion = semver . maxSatisfying ( availableVersions , `^${ version . toString ( ) } ` ) ;
88- await context . globalState . update ( cacheKey , selectedVersion ?? undefined ) ;
88+ await context . globalState . update ( cacheKey , selectedVersion ? selectedVersion . raw : undefined ) ;
8989 return selectedVersion ?? version ;
9090 } catch {
9191 const selectedVersion = context . globalState . get < string | null > ( cacheKey , null ) ;
@@ -597,6 +597,16 @@ export async function setupZig(context: vscode.ExtensionContext) {
597597 await workspaceConfigUpdateNoThrow ( zigConfig , "initialSetupDone" , undefined , true ) ;
598598
599599 await context . workspaceState . update ( "zig-version" , undefined ) ;
600+
601+ // Remove incorrect values in the global state that have been added by
602+ // an older version of the extension.
603+ for ( const key of context . globalState . keys ( ) ) {
604+ if ( ! key . startsWith ( "zig-satisfying-version-" ) ) continue ;
605+ const value = context . globalState . get ( key ) ;
606+ if ( value !== undefined && typeof value !== "string" ) {
607+ await context . globalState . update ( key , undefined ) ;
608+ }
609+ }
600610 }
601611
602612 /// Workaround https://github.com/ziglang/zig/issues/21905
0 commit comments