Skip to content

Commit c574d3d

Browse files
dyniecfendor
authored andcommitted
Update global config on extension restart
1 parent ed677d8 commit c574d3d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import * as constants from './commands/constants';
1111
import * as DocsBrowser from './docsBrowser';
1212
import { HlsError, MissingToolError, NoMatchingHls } from './errors';
13-
import { findHaskellLanguageServer, HlsExecutable, IEnvVars } from './hlsBinaries';
13+
import { findHaskellLanguageServer, HlsExecutable, IEnvVars, fetchConfig } from './hlsBinaries';
1414
import { addPathToProcessPath, comparePVP, callAsync } from './utils';
1515
import { Config, initConfig, initLoggerFromConfig, logConfig } from './config';
1616
import { HaskellStatusBar } from './statusBar';
@@ -83,6 +83,7 @@ export async function activate(context: ExtensionContext) {
8383
await langClient?.client.stop();
8484
}
8585
clients.clear();
86+
fetchConfig();
8687

8788
for (const document of workspace.textDocuments) {
8889
await activateServer(context, document);

src/hlsBinaries.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from './utils';
1414
import { ToolConfig, Tool, initDefaultGHCup, GHCup, GHCupConfig } from './ghcup';
1515
import { getHlsMetadata } from './metadata';
16-
export { IEnvVars };
16+
export { IEnvVars, fetchConfig };
1717

1818
export type Context = {
1919
manageHls: ManageHLS;
@@ -25,7 +25,7 @@ export type Context = {
2525
/**
2626
* Global configuration for this extension.
2727
*/
28-
const haskellConfig = workspace.getConfiguration('haskell');
28+
let haskellConfig = workspace.getConfiguration('haskell');
2929

3030
/**
3131
* On Windows the executable needs to be stored somewhere with an .exe extension
@@ -35,6 +35,11 @@ const exeExt = process.platform === 'win32' ? '.exe' : '';
3535
type ManageHLS = 'GHCup' | 'PATH';
3636
let manageHLS = haskellConfig.get('manageHLS') as ManageHLS;
3737

38+
function fetchConfig() {
39+
haskellConfig = workspace.getConfiguration('haskell');
40+
manageHLS = haskellConfig.get('manageHLS') as ManageHLS;
41+
}
42+
3843
/**
3944
* Gets serverExecutablePath and fails if it's not set.
4045
* @param logger Log progress.

0 commit comments

Comments
 (0)