diff --git a/src/utils/settingUtils.ts b/src/utils/settingUtils.ts index 7b6eb6c..a874342 100644 --- a/src/utils/settingUtils.ts +++ b/src/utils/settingUtils.ts @@ -3,6 +3,8 @@ import { workspace, WorkspaceConfiguration } from "vscode"; import { DescriptionConfiguration } from "../shared"; +import { sep } from "path"; + export function getWorkspaceConfiguration(): WorkspaceConfiguration { return workspace.getConfiguration("leetcode"); @@ -13,7 +15,7 @@ export function shouldHideSolvedProblem(): boolean { } export function getWorkspaceFolder(): string { - return getWorkspaceConfiguration().get("workspaceFolder", ""); + return substitute(getWorkspaceConfiguration().get("workspaceFolder", "")); } export function getEditorShortcuts(): string[] { @@ -66,3 +68,29 @@ export interface IDescriptionConfiguration { showInComment: boolean; showInWebview: boolean; } + +function substitute(val: T): T { + if (typeof val == 'string') { + val = val.replace(/\$\{(.*?)\}/g, (match, name) => { + const rep = replace(name); + return (rep === null) ? match : rep; + }) as unknown as T; + } + return val; +} + +function replace(name: string): string | null { + if (name == 'pathSeparator') { + return sep as string; + } + const envPrefix = 'env:'; + if (name.startsWith(envPrefix)) + return process.env[name.substring(envPrefix.length)] || ''; + const configPrefix = 'config:'; + if (name.startsWith(configPrefix)) { + const config = workspace.getConfiguration().get( + name.substring(configPrefix.length)); + return (typeof config == 'string') ? config : null; + } + return null; +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy