@@ -73,7 +73,6 @@ class MissingToolError extends Error {
73
73
* @param callback Upon process termination, execute this callback. If given, must resolve promise.
74
74
* @returns Stdout of the process invocation, trimmed off newlines, or whatever the `callback` resolved to.
75
75
*/
76
-
77
76
async function callAsync (
78
77
binary : string ,
79
78
args : string [ ] ,
@@ -177,14 +176,16 @@ function findHLSinPATH(context: ExtensionContext, logger: Logger, folder?: Works
177
176
}
178
177
179
178
/**
180
- * Downloads the latest haskell-language-server binaries via ghcup.
179
+ * Downloads the latest haskell-language-server binaries via GHCup.
180
+ * Makes sure that either `ghcup` is available locally, otherwise installs
181
+ * it into an isolated location.
181
182
* If we figure out the correct GHC version, but it isn't compatible with
182
183
* the latest HLS executables, we download the latest compatible HLS binaries
183
184
* as a fallback.
184
185
*
185
186
* @param context Context of the extension, required for metadata.
186
187
* @param logger Logger for progress updates.
187
- * @param workingDir Directory in which the process shall be executed .
188
+ * @param workingDir Working directory in VSCode .
188
189
* @returns Path to haskell-language-server-wrapper
189
190
*/
190
191
export async function findHaskellLanguageServer (
@@ -308,9 +309,17 @@ async function getLatestSuitableHLS(
308
309
undefined ,
309
310
false ,
310
311
) ;
312
+ // Output looks like:
313
+ // ```
314
+ // hls 1.5.1
315
+ // hls 1.6.0.0
316
+ // hls 1.6.1.0 latest,recommended
317
+ // hls 1.6.1.1 stray
318
+ // ```
319
+ // and we want the `1.6.1.1`
311
320
const latestHlsVersion = hlsVersions . split ( / \r ? \n / ) . pop ( ) ! . split ( ' ' ) [ 1 ] ;
312
321
313
- // get project GHC version
322
+ // get project GHC version, but fallback to system ghc if necessary.
314
323
const projectGhc =
315
324
wrapper === undefined
316
325
? await callAsync ( `ghc${ exeExt } ` , [ '--numeric-version' ] , storagePath , logger , undefined , false )
@@ -350,6 +359,7 @@ export async function getProjectGHCVersion(
350
359
if ( stdout ) {
351
360
logger . error ( `stdout: ${ stdout } ` ) ;
352
361
}
362
+ // Error message emitted by HLS-wrapper
353
363
const regex = / C r a d l e r e q u i r e s ( .+ ) b u t c o u l d n ' t f i n d i t / ;
354
364
const res = regex . exec ( stderr ) ;
355
365
if ( res ) {
0 commit comments