File tree 1 file changed +20
-10
lines changed 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -546,24 +546,34 @@ async function getLatestHLSfromGHCup(
546
546
undefined ,
547
547
false ,
548
548
) ;
549
- const latestHlsVersion = hlsVersions . split ( / \r ? \n / ) . pop ( ) ! . split ( ' ' ) [ 1 ] ;
549
+ const installedHLSVersions = hlsVersions . split ( / \r ? \n / ) . pop ( ) ! . split ( ' ' ) ;
550
+
550
551
let bindir = await callGHCup ( context , logger ,
551
552
[ 'whereis' , 'bindir' ] ,
552
553
undefined ,
553
554
false
554
555
) ;
555
556
556
- let hlsBin = '' ;
557
- if ( targetGhc ) {
558
- hlsBin = path . join ( bindir , `haskell-language-server-${ targetGhc } ~${ latestHlsVersion } ${ exeExt } ` ) ;
559
- } else {
560
- hlsBin = path . join ( bindir , `haskell-language-server-wrapper-${ latestHlsVersion } ${ exeExt } ` ) ;
561
- }
562
557
563
- if ( fs . existsSync ( hlsBin ) ) {
564
- return [ latestHlsVersion , hlsBin ] ;
558
+ const hlses = installedHLSVersions . map ( hls => {
559
+ let hlsBin = '' ;
560
+ if ( targetGhc ) {
561
+ hlsBin = path . join ( bindir , `haskell-language-server-${ targetGhc } ~${ hls } ${ exeExt } ` ) ;
562
+ } else {
563
+ hlsBin = path . join ( bindir , `haskell-language-server-wrapper-${ hls } ${ exeExt } ` ) ;
564
+ }
565
+
566
+ if ( fs . existsSync ( hlsBin ) ) {
567
+ return [ hls , hlsBin ] ;
568
+ } else {
569
+ return null ;
570
+ }
571
+ } ) . filter ( e => e !== null ) ;
572
+
573
+ if ( hlses . length > 0 ) {
574
+ return hlses [ hlses . length - 1 ] as [ string , string ] ;
565
575
} else {
566
- return null ;
576
+ return null ;
567
577
}
568
578
}
569
579
You can’t perform that action at this time.
0 commit comments