Skip to content

Commit 0026cec

Browse files
author
Kartik Raj
authored
Add support for referencing multiroot-workspace folders in settings using ${workspaceFolder:<folder_name>} (#19188)
* Add support for referencing multiroot-workspace folders in settings using `${workspaceFolder:<folder_name>}` * Fix tests * Fix more tests * IOops * Alternate
1 parent 121da78 commit 0026cec

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

news/1 Enhancements/18650.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for referencing multiroot-workspace folders in settings using `${workspaceFolder:<folder_name>}`.

src/client/common/variables/systemVariables.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as Path from 'path';
77
import { Range, Uri } from 'vscode';
88

99
import { IDocumentManager, IWorkspaceService } from '../application/types';
10+
import { WorkspaceService } from '../application/workspace';
1011
import * as Types from '../utils/sysTypes';
1112
import { IStringDictionary, ISystemVariables } from './types';
1213

@@ -125,6 +126,16 @@ export class SystemVariables extends AbstractSystemVariables {
125126
string | undefined
126127
>)[`env.${key}`] = process.env[key];
127128
});
129+
workspace = workspace ?? new WorkspaceService();
130+
try {
131+
workspace.workspaceFolders?.forEach((folder) => {
132+
const basename = Path.basename(folder.uri.fsPath);
133+
((this as any) as Record<string, string | undefined>)[`workspaceFolder:${basename}`] =
134+
folder.uri.fsPath;
135+
});
136+
} catch {
137+
// This try...catch block is here to support pre-existing tests, ignore error.
138+
}
128139
}
129140

130141
public get cwd(): string {

0 commit comments

Comments
 (0)