Skip to content

Commit

Permalink
Fix cwd. (#6619)
Browse files Browse the repository at this point in the history
Fixes #6618
  • Loading branch information
sean-mcmanus committed Dec 3, 2020
1 parent a3de2f9 commit aa4c5df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,13 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
newConfig.preLaunchTask = task.name;
newConfig.externalConsole = false;
const exeName: string = path.join("${fileDirname}", "${fileBasenameNoExtension}");
newConfig.program = platform === "win32" ? exeName + ".exe" : exeName;
const isWindows: boolean = platform === 'win32';
newConfig.program = isWindows ? exeName + ".exe" : exeName;
// Add the "detail" property to show the compiler path in QuickPickItem.
// This property will be removed before writing the DebugConfiguration in launch.json.
newConfig.detail = task.detail ? task.detail : definition.command;
const isCl: boolean = compilerName === "cl.exe";
newConfig.cwd = isWindows && !isCl && !process.env.PATH?.includes(compilerPath) ? path.dirname(compilerPath) : "${workspaceFolder}";

return new Promise<vscode.DebugConfiguration>(resolve => {
if (platform === "darwin") {
Expand All @@ -201,7 +204,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
debuggerName = "gdb";
}

if (platform === "win32") {
if (isWindows) {
debuggerName += ".exe";
}

Expand Down
2 changes: 1 addition & 1 deletion Extension/src/LanguageServer/cppBuildTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class CppBuildTaskProvider implements TaskProvider {
if (compilerArgs && compilerArgs.length > 0) {
args = args.concat(compilerArgs);
}
const cwd: string = isCl ? "${workspaceFolder}" : path.dirname(compilerPath);
const cwd: string = isWindows && !isCl && !process.env.PATH?.includes(compilerPath) ? path.dirname(compilerPath) : "${workspaceFolder}";
const options: cp.ExecOptions | undefined = { cwd: cwd };
definition = {
type: CppBuildTaskProvider.CppBuildScriptType,
Expand Down

0 comments on commit aa4c5df

Please sign in to comment.