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