Skip to content

Commit b0863aa

Browse files
authored
Support projectPath: '${file}' (#8472)
1 parent 4cb5e00 commit b0863aa

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/shared/dotnetConfigurationProvider.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,24 @@ class InternalServiceError extends Error {}
3030
class UnavaliableLaunchServiceError extends Error {}
3131

3232
const workspaceFolderToken = '${workspaceFolder}';
33+
const fileToken = '${file}';
34+
3335
/**
34-
* Replaces '${workspaceFolder}' with the current folder while keeping path separators consistent.
36+
* Replaces some '${variable}' tokens.
3537
*
3638
* @param projectPath The expected path to the .csproj
3739
* @param folderPath The current workspace folder
3840
* @returns A fully resolved path to the .csproj
3941
*/
40-
function resolveWorkspaceFolderToken(projectPath: string, folderPath: string): string {
42+
function resolveVariableTokens(projectPath: string, folderPath: string): string {
43+
if (projectPath === fileToken) {
44+
return vscode.window.activeTextEditor?.document.fileName ?? projectPath;
45+
}
46+
4147
if (projectPath.startsWith(workspaceFolderToken)) {
4248
const relativeProjectPath: string = projectPath.substring(workspaceFolderToken.length);
4349

44-
// Keep the path seperate consistant
50+
// Keep the path separators consistent
4551
if (relativeProjectPath.startsWith('/')) {
4652
folderPath = folderPath.replace(/[\\/]+/g, '/');
4753
} else {
@@ -91,7 +97,7 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
9197
let projectPath: string | undefined = debugConfiguration.projectPath;
9298
if (folder) {
9399
if (projectPath) {
94-
projectPath = resolveWorkspaceFolderToken(projectPath, folder.uri.fsPath);
100+
projectPath = resolveVariableTokens(projectPath, folder.uri.fsPath);
95101
}
96102

97103
const dotnetDebugServiceProxy = await getServiceBroker()?.getProxy<IDotnetDebugConfigurationService>(

0 commit comments

Comments
 (0)