Skip to content

Commit 05bc130

Browse files
committed
- Address launch config not being able to be found on windows
- Added comments to make the intent more explicit
1 parent ac7920b commit 05bc130

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/debugger/launch.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,27 @@ export function getLaunchConfiguration(
113113
const wsLaunchSection = vscode.workspace.getConfiguration("launch", folderCtx.workspaceFolder);
114114
const launchConfigs = wsLaunchSection.get<vscode.DebugConfiguration[]>("configurations") || [];
115115
const { folder } = getFolderAndNameSuffix(folderCtx);
116-
const buildDirectory = BuildFlags.buildDirectoryFromWorkspacePath(folder, true);
116+
const targetPath = path.join(
117+
BuildFlags.buildDirectoryFromWorkspacePath(folder, true),
118+
"debug",
119+
target
120+
);
121+
// Users could be on different platforms with different path annotations,
122+
// so normalize before we compare.
117123
return launchConfigs.find(
118-
config => config.program === path.join(buildDirectory, "debug", target)
124+
config => path.normalize(config.program) === path.normalize(targetPath)
119125
);
120126
}
121127

122128
// Return array of DebugConfigurations for executables based on what is in Package.swift
123129
function createExecutableConfigurations(ctx: FolderContext): vscode.DebugConfiguration[] {
124130
const executableProducts = ctx.swiftPackage.executableProducts;
131+
132+
// Windows understand the forward slashes, so make the configuration unified as posix path
133+
// to make it easier for users switching between platforms.
125134
const { folder, nameSuffix } = getFolderAndNameSuffix(ctx, undefined, "posix");
126135
const buildDirectory = BuildFlags.buildDirectoryFromWorkspacePath(folder, true, "posix");
136+
127137
return executableProducts.flatMap(product => {
128138
const baseConfig = {
129139
type: DebugAdapter.getLaunchConfigType(ctx.workspaceContext.swiftVersion),

0 commit comments

Comments
 (0)