Skip to content

Commit cc58c9a

Browse files
committed
Consider all locally compiled versions
1 parent 6ebfdef commit cc58c9a

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/hlsBinaries.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -546,24 +546,34 @@ async function getLatestHLSfromGHCup(
546546
undefined,
547547
false,
548548
);
549-
const latestHlsVersion = hlsVersions.split(/\r?\n/).pop()!.split(' ')[1];
549+
const installedHLSVersions = hlsVersions.split(/\r?\n/).pop()!.split(' ');
550+
550551
let bindir = await callGHCup(context, logger,
551552
['whereis', 'bindir'],
552553
undefined,
553554
false
554555
);
555556

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-
}
562557

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];
565575
} else {
566-
return null;
576+
return null;
567577
}
568578
}
569579

0 commit comments

Comments
 (0)