@@ -30,7 +30,7 @@ export { IEnvVars };
30
30
export type ReleaseMetadata = Map < string , Map < string , Map < string , string [ ] > > > ;
31
31
32
32
type ManageHLS = 'GHCup' | 'PATH' ;
33
- let manageHLS = workspace . getConfiguration ( 'haskell' ) . get ( 'manageHLS' ) as ManageHLS | null ;
33
+ let manageHLS = workspace . getConfiguration ( 'haskell' ) . get ( 'manageHLS' ) as ManageHLS ;
34
34
35
35
// On Windows the executable needs to be stored somewhere with an .exe extension
36
36
const exeExt = process . platform === 'win32' ? '.exe' : '' ;
@@ -239,12 +239,14 @@ export async function findHaskellLanguageServer(
239
239
fs . mkdirSync ( storagePath ) ;
240
240
}
241
241
242
- if ( ! manageHLS ) {
243
- // plugin needs initialization
242
+
243
+ // first plugin initialization
244
+ if ( manageHLS !== 'GHCup' && ! context . globalState . get ( "pluginInitialized" ) as boolean | null ) {
244
245
const promptMessage = 'How do you want the extension to manage/discover HLS and the relevant toolchain?' ;
245
246
246
- const decision =
247
- ( await window . showInformationMessage ( promptMessage , 'Automatically via GHCup' , 'Manually via PATH' ) ) || null ;
247
+ const popup = window . showInformationMessage ( promptMessage , 'Automatically via GHCup' , 'Manually via PATH' ) ;
248
+
249
+ const decision = ( await popup ) || null ;
248
250
if ( decision === 'Automatically via GHCup' ) {
249
251
manageHLS = 'GHCup' ;
250
252
} else if ( decision === 'Manually via PATH' ) {
@@ -256,9 +258,10 @@ export async function findHaskellLanguageServer(
256
258
manageHLS = 'PATH' ;
257
259
}
258
260
workspace . getConfiguration ( 'haskell' ) . update ( 'manageHLS' , manageHLS , ConfigurationTarget . Global ) ;
261
+ context . globalState . update ( "pluginInitialized" , true ) ;
259
262
}
260
263
261
- if ( manageHLS === 'PATH' || manageHLS === null ) {
264
+ if ( manageHLS === 'PATH' ) {
262
265
return findHLSinPATH ( context , logger , folder ) ;
263
266
} else {
264
267
// we manage HLS, make sure ghcup is installed/available
@@ -550,15 +553,7 @@ async function getLatestToolFromGHCup(context: ExtensionContext, logger: Logger,
550
553
) ;
551
554
const latestInstalled = installedVersions . split ( / \r ? \n / ) . pop ( ) ;
552
555
if ( latestInstalled ) {
553
- const latestInstalledVersion = latestInstalled . split ( / \s + / ) [ 1 ] ;
554
-
555
- const bin = await callGHCup ( context , logger , [ 'whereis' , tool , `${ latestInstalledVersion } ` ] , undefined , false ) ;
556
- const ver = await callAsync ( `${ bin } ` , [ '--numeric-version' ] , logger , undefined , undefined , false ) ;
557
- if ( ver ) {
558
- return ver ;
559
- } else {
560
- throw new Error ( `Could not figure out version of ${ bin } ` ) ;
561
- }
556
+ return latestInstalled . split ( / \s + / ) [ 1 ] ;
562
557
}
563
558
564
559
return getLatestAvailableToolFromGHCup ( context , logger , tool ) ;
0 commit comments