@@ -85,7 +85,7 @@ class NoBinariesError extends Error {
85
85
const supportedReleasesLink =
86
86
'[See the list of supported versions here](https://github.com/haskell/vscode-haskell#supported-ghc-versions)' ;
87
87
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 ( ) } .
89
89
${ supportedReleasesLink } ` ) ;
90
90
} else {
91
91
super ( `haskell-language-server ${ hlsVersion } is not available on ${ os . type ( ) } .
@@ -205,7 +205,7 @@ async function getProjectGhcVersion(
205
205
return callWrapper ( downloadedWrapper ) ;
206
206
}
207
207
208
- async function getLatestReleaseMetadata ( context : ExtensionContext , storagePath : string ) : Promise < IRelease [ ] | null > {
208
+ async function getReleaseMetadata ( context : ExtensionContext , storagePath : string ) : Promise < IRelease [ ] | null > {
209
209
const releasesUrl = workspace . getConfiguration ( 'haskell' ) . releasesURL
210
210
? url . parse ( workspace . getConfiguration ( 'haskell' ) . releasesURL )
211
211
: undefined ;
@@ -219,7 +219,7 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath:
219
219
path : '/repos/haskell/haskell-language-server/releases' ,
220
220
} ;
221
221
222
- const offlineCache = path . join ( storagePath , 'latestApprovedRelease .cache.json' ) ;
222
+ const offlineCache = path . join ( storagePath , 'approvedReleases .cache.json' ) ;
223
223
224
224
async function readCachedReleaseData ( ) : Promise < IRelease [ ] | null > {
225
225
try {
@@ -242,15 +242,16 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath:
242
242
243
243
try {
244
244
const releaseInfo = await httpsGetSilently ( opts ) ;
245
- const latestInfoParsed =
245
+ const releaseInfoParsed =
246
246
validate . parseAndValidate ( releaseInfo , githubReleaseApiValidator ) . filter ( ( x ) => ! x . prerelease ) || null ;
247
247
248
248
if ( updateBehaviour === 'prompt' ) {
249
249
const cachedInfoParsed = await readCachedReleaseData ( ) ;
250
250
251
251
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 )
254
255
) {
255
256
const promptMessage =
256
257
cachedInfoParsed === null
@@ -266,8 +267,8 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath:
266
267
}
267
268
268
269
// 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 ;
271
272
} catch ( githubError : any ) {
272
273
// Attempt to read from the latest cached file
273
274
try {
@@ -316,7 +317,7 @@ export async function downloadHaskellLanguageServer(
316
317
}
317
318
318
319
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 ) ;
320
321
if ( ! releases ) {
321
322
let message = "Couldn't find any pre-built haskell-language-server binaries" ;
322
323
const updateBehaviour = workspace . getConfiguration ( 'haskell' ) . get ( 'updateBehavior' ) as UpdateBehaviour ;
@@ -364,6 +365,11 @@ export async function downloadHaskellLanguageServer(
364
365
window . showInformationMessage ( new NoBinariesError ( releases [ 0 ] . tag_name , ghcVersion ) . message ) ;
365
366
return null ;
366
367
}
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
+ }
367
373
368
374
const serverName = `haskell-language-server-${ release ?. tag_name } -${ process . platform } -${ ghcVersion } ${ exeExt } ` ;
369
375
const binaryDest = path . join ( storagePath , serverName ) ;
0 commit comments