diff --git a/README.md b/README.md index 5a2e7ab..7c88d32 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Provide run settings for the languages you use in `settings.json`. Here are some We can use the following variables in the syntax of `${...}` - Most of [VSCode's built-in variables](https://code.visualstudio.com/docs/editor/variables-reference) - `${exeExtname}` returns `.exe` for Windows and an empty string for other platforms -- `${path:*some value*}` turns \*some value\* into a valid path string for the current platform, which normalizes slashes and handles spaces +- `${path:*value*}` normalizes \*value\* into a valid path string for the current platform
Possible settings per language diff --git a/src/extension/util.ts b/src/extension/util.ts index 5554709..1bcadc0 100644 --- a/src/extension/util.ts +++ b/src/extension/util.ts @@ -40,10 +40,6 @@ async function replaceAsync(string: string, regexp: RegExp, replacer: Function) return string.replace(regexp, () => replacements[i++]); } -function normalizePath(str: string) { - return path.normalize(os.platform() === 'win32' ? `"${str}"` : str.replace(/ /g, '\ ')); -} - export interface ILanguageRunSettings { compileCommand?: string; runCommand: string; @@ -232,7 +228,7 @@ export async function resolveVariables(string: string, recursive: boolean = fals string = string.replace(/\${env:(.*?)}/g, match => process.env[match] ?? ''); string = string.replace(/\${config:(.*?)}/g, match => vscode.workspace.getConfiguration().get(match) ?? ''); string = string.replace(/\${exeExtname}/, os.platform() === 'win32' ? '.exe' : ''); - string = await replaceAsync(string, /\${path:(.*?)}/g, async (match: string) => normalizePath(await resolveVariables(match, false, inContextOfFile))); + string = await replaceAsync(string, /\${path:(.*?)}/g, async (match: string) => path.normalize(await resolveVariables(match, false, inContextOfFile))); } while (recursive && oldString !== string); return string; }