@@ -85,7 +85,7 @@ class NoBinariesError extends Error {
8585 const supportedReleasesLink =
8686 '[See the list of supported versions here](https://github.com/haskell/vscode-haskell#supported-ghc-versions)' ;
8787 if ( ghcVersion ) {
88- super ( `haskell-language-server ${ hlsVersion } for GHC ${ ghcVersion } is not available on ${ os . type ( ) } .
88+ super ( `haskell-language-server ${ hlsVersion } or earlier for GHC ${ ghcVersion } is not available on ${ os . type ( ) } .
8989 ${ supportedReleasesLink } ` ) ;
9090 } else {
9191 super ( `haskell-language-server ${ hlsVersion } is not available on ${ os . type ( ) } .
@@ -205,7 +205,7 @@ async function getProjectGhcVersion(
205205 return callWrapper ( downloadedWrapper ) ;
206206}
207207
208- async function getLatestReleaseMetadata ( context : ExtensionContext , storagePath : string ) : Promise < IRelease [ ] | null > {
208+ async function getReleaseMetadata ( context : ExtensionContext , storagePath : string ) : Promise < IRelease [ ] | null > {
209209 const releasesUrl = workspace . getConfiguration ( 'haskell' ) . releasesURL
210210 ? url . parse ( workspace . getConfiguration ( 'haskell' ) . releasesURL )
211211 : undefined ;
@@ -219,7 +219,7 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath:
219219 path : '/repos/haskell/haskell-language-server/releases' ,
220220 } ;
221221
222- const offlineCache = path . join ( storagePath , 'latestApprovedRelease .cache.json' ) ;
222+ const offlineCache = path . join ( storagePath , 'approvedReleases .cache.json' ) ;
223223
224224 async function readCachedReleaseData ( ) : Promise < IRelease [ ] | null > {
225225 try {
@@ -242,15 +242,16 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath:
242242
243243 try {
244244 const releaseInfo = await httpsGetSilently ( opts ) ;
245- const latestInfoParsed =
245+ const releaseInfoParsed =
246246 validate . parseAndValidate ( releaseInfo , githubReleaseApiValidator ) . filter ( ( x ) => ! x . prerelease ) || null ;
247247
248248 if ( updateBehaviour === 'prompt' ) {
249249 const cachedInfoParsed = await readCachedReleaseData ( ) ;
250250
251251 if (
252- latestInfoParsed !== null &&
253- ( cachedInfoParsed === null || latestInfoParsed [ 0 ] . tag_name !== cachedInfoParsed [ 0 ] . tag_name )
252+ releaseInfoParsed !== null && releaseInfoParsed . length > 0 &&
253+ ( cachedInfoParsed === null || cachedInfoParsed . length == 0
254+ || releaseInfoParsed [ 0 ] . tag_name !== cachedInfoParsed [ 0 ] . tag_name )
254255 ) {
255256 const promptMessage =
256257 cachedInfoParsed === null
@@ -266,8 +267,8 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath:
266267 }
267268
268269 // Cache the latest successfully fetched release information
269- await promisify ( fs . writeFile ) ( offlineCache , JSON . stringify ( latestInfoParsed ) , { encoding : 'utf-8' } ) ;
270- return latestInfoParsed ;
270+ await promisify ( fs . writeFile ) ( offlineCache , JSON . stringify ( releaseInfoParsed ) , { encoding : 'utf-8' } ) ;
271+ return releaseInfoParsed ;
271272 } catch ( githubError : any ) {
272273 // Attempt to read from the latest cached file
273274 try {
@@ -316,7 +317,7 @@ export async function downloadHaskellLanguageServer(
316317 }
317318
318319 logger . info ( 'Fetching the latest release from GitHub or from cache' ) ;
319- const releases = await getLatestReleaseMetadata ( context , storagePath ) ;
320+ const releases = await getReleaseMetadata ( context , storagePath ) ;
320321 if ( ! releases ) {
321322 let message = "Couldn't find any pre-built haskell-language-server binaries" ;
322323 const updateBehaviour = workspace . getConfiguration ( 'haskell' ) . get ( 'updateBehavior' ) as UpdateBehaviour ;
@@ -364,6 +365,11 @@ export async function downloadHaskellLanguageServer(
364365 window . showInformationMessage ( new NoBinariesError ( releases [ 0 ] . tag_name , ghcVersion ) . message ) ;
365366 return null ;
366367 }
368+ if ( release ?. tag_name != releases [ 0 ] . tag_name ) {
369+ const message = `haskell-language-server ${ releases [ 0 ] . tag_name } for GHC ${ ghcVersion } is not available on ${ os . type ( ) } . Falling back to haskell-language-server ${ release ?. tag_name } `
370+ logger . warn ( message )
371+ window . showInformationMessage ( message )
372+ }
367373
368374 const serverName = `haskell-language-server-${ release ?. tag_name } -${ process . platform } -${ ghcVersion } ${ exeExt } ` ;
369375 const binaryDest = path . join ( storagePath , serverName ) ;
0 commit comments