Skip to content

Commit 94a2b67

Browse files
bobbrowsean-mcmanus
authored andcommitted
add support for ${workspaceFolder:<folder_name>}
1 parent 5883747 commit 94a2b67

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Extension/src/common.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export function resolveVariables(input: string, additionalEnvironment: {[key: st
152152
}
153153

154154
// Replace environment and configuration variables.
155-
let regexp: RegExp = /\$\{((env|config)(.|:))?(.*?)\}/g;
155+
let regexp: RegExp = /\$\{((env|config|workspaceFolder)(.|:))?(.*?)\}/g;
156156
let ret: string = input.replace(regexp, (match: string, ignored1: string, varType: string, ignored2: string, name: string) => {
157157
// Historically, if the variable didn't have anything before the "." or ":"
158158
// it was assumed to be an environment variable
@@ -180,6 +180,18 @@ export function resolveVariables(input: string, additionalEnvironment: {[key: st
180180
newValue = (config) ? config.toString() : undefined;
181181
break;
182182
}
183+
case "workspaceFolder": {
184+
// Only replace ${workspaceFolder:name} variables for now.
185+
// We may consider doing replacement of ${workspaceFolder} here later, but we would have to update the language server and also
186+
// intercept messages with paths in them and add the ${workspaceFolder} variable back in (e.g. for light bulb suggestions)
187+
if (name && vscode.workspace && vscode.workspace.workspaceFolders) {
188+
let folder: vscode.WorkspaceFolder = vscode.workspace.workspaceFolders.find(folder => folder.name.toLocaleLowerCase() === name.toLocaleLowerCase());
189+
if (folder) {
190+
newValue = folder.uri.fsPath;
191+
}
192+
}
193+
break;
194+
}
183195
default: { assert.fail("unknown varType matched"); }
184196
}
185197
return (newValue) ? newValue : match;

0 commit comments

Comments
 (0)