Skip to content

Commit aeb4636

Browse files
committed
More cleanup
1 parent 6dc0e29 commit aeb4636

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/hlsBinaries.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ export async function findHaskellLanguageServer(
252252

253253
// get a preliminary toolchain for finding the correct project GHC version (we need HLS and cabal/stack and ghc as fallback),
254254
// later we may install a different toolchain that's more project-specific
255-
let latestHLS = await getLatestToolFromGHCup(context, logger, 'hls');
256-
let latestCabal = (workspace.getConfiguration('haskell').get('installCabal') as boolean)
255+
const latestHLS = await getLatestToolFromGHCup(context, logger, 'hls');
256+
const latestCabal = (workspace.getConfiguration('haskell').get('installCabal') as boolean)
257257
? await getLatestToolFromGHCup(context, logger, 'cabal')
258258
: null;
259-
let latestStack = (workspace.getConfiguration('haskell').get('installStack') as boolean)
259+
const latestStack = (workspace.getConfiguration('haskell').get('installStack') as boolean)
260260
? await getLatestToolFromGHCup(context, logger, 'stack')
261261
: null;
262-
let recGHC =
262+
const recGHC =
263263
!executableExists('ghc') && (workspace.getConfiguration('haskell').get('installGHC') as boolean)
264264
? await getLatestAvailableToolFromGHCup(context, logger, 'ghc', 'recommended')
265265
: null;
@@ -283,23 +283,19 @@ export async function findHaskellLanguageServer(
283283

284284
// now figure out the project GHC version and the latest supported HLS version
285285
// we need for it (e.g. this might in fact be a downgrade for old GHCs)
286-
const [installableHls, projectGhc] = await getLatestHLS(context, logger, workingDir, latestToolchainBindir);
287-
288-
latestHLS = await getLatestToolFromGHCup(context, logger, 'hls')
289-
latestCabal = latestCabal ? await getLatestToolFromGHCup(context, logger, 'cabal') : null;
290-
latestStack = latestStack ? await getLatestToolFromGHCup(context, logger, 'stack') : null;
286+
const [projectHls, projectGhc] = await getLatestProjectHLS(context, logger, workingDir, latestToolchainBindir);
291287

292288
// now install said version in an isolated symlink directory
293289
return await callGHCup(
294290
context,
295291
logger,
296292
[ 'run'
297-
, '--hls', installableHls
293+
, '--hls', projectHls
298294
, ...(latestCabal ? ['--cabal', latestCabal] : [])
299295
, ...(latestStack ? ['--stack', latestStack] : [])
300296
, ...((workspace.getConfiguration('haskell').get('installGHC') as boolean) ? ['--ghc', projectGhc] : [])
301297
, '--install'],
302-
`Installing project specific toolchain: HLS-${installableHls}, GHC-${projectGhc}, cabal-${latestCabal}, stack-${latestStack}`,
298+
`Installing project specific toolchain: HLS-${projectHls}, GHC-${projectGhc}, cabal-${latestCabal}, stack-${latestStack}`,
303299
true
304300
);
305301
}
@@ -337,7 +333,7 @@ async function callGHCup(
337333
}
338334
}
339335

340-
async function getLatestHLS(
336+
async function getLatestProjectHLS(
341337
context: ExtensionContext,
342338
logger: Logger,
343339
workingDir: string,

test/suite/extension.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ suite('Extension Test Suite', () => {
187187
test('Server should inherit environment variables defined in the settings', async () => {
188188
await vscode.workspace.openTextDocument(getWorkspaceFile('Main.hs'));
189189
assert.ok(
190-
retryOperation(() => new Promise((resolve, reject) => (filesCreated.get('cache')!)), 1000 * 5, 20),
190+
retryOperation(() => new Promise((resolve, reject) => filesCreated.get('cache')!), 1000 * 5, 20),
191191
'Server did not inherit XDG_CACHE_DIR from environment variables set in the settings'
192192
);
193193
});

0 commit comments

Comments
 (0)