Unnamed repository; edit this file 'description' to name the repository.
Don't pretend to have a WorkspaceConfiguration if there isn't one
| -rw-r--r-- | editors/code/src/client.ts | 2 | ||||
| -rw-r--r-- | editors/code/src/config.ts | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 073ff2f470..cb71a01138 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -13,7 +13,7 @@ import { RaLanguageClient } from "./lang_client"; export async function createClient( traceOutputChannel: vscode.OutputChannel, outputChannel: vscode.OutputChannel, - initializationOptions: vscode.WorkspaceConfiguration, + initializationOptions: lc.LanguageClientOptions["initializationOptions"], serverOptions: lc.ServerOptions, config: Config, unlinkedFiles: vscode.Uri[], diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 3b1b0768d3..06e179eb0e 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -5,6 +5,7 @@ import * as vscode from "vscode"; import { expectNotUndefined, log, normalizeDriveLetter, unwrapUndefinable } from "./util"; import type { Env } from "./util"; import type { Disposable } from "vscode"; +import { get } from "lodash"; export type RunnableEnvCfgItem = { mask?: string; @@ -12,6 +13,9 @@ export type RunnableEnvCfgItem = { platform?: string | string[]; }; +export type ConfigurationTree = { [key: string]: ConfigurationValue }; +export type ConfigurationValue = undefined | null | boolean | number | string | ConfigurationValue[] | ConfigurationTree; + type ShowStatusBar = "always" | "never" | { documentSelector: vscode.DocumentSelector }; export class Config { @@ -197,7 +201,7 @@ export class Config { * So this getter handles this quirk by not requiring the caller to use postfix `!` */ private get<T>(path: string): T | undefined { - return prepareVSCodeConfig(this.cfg.get<T>(path)); + return prepareVSCodeConfig(get(this.cfg, path)) as T; } get serverPath() { @@ -371,22 +375,20 @@ export class Config { } } -export function prepareVSCodeConfig<T>(resp: T): T { +export function prepareVSCodeConfig(resp: ConfigurationValue): ConfigurationValue { if (Is.string(resp)) { - return substituteVSCodeVariableInString(resp) as T; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } else if (resp && Is.array<any>(resp)) { + return substituteVSCodeVariableInString(resp); + } else if (resp && Is.array(resp)) { return resp.map((val) => { return prepareVSCodeConfig(val); - }) as T; + }); } else if (resp && typeof resp === "object") { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const res: { [key: string]: any } = {}; + const res: ConfigurationTree = {}; for (const key in resp) { const val = resp[key]; res[key] = prepareVSCodeConfig(val); } - return res as T; + return res; } return resp; } |