Skip to content

Commit a0ee7a1

Browse files
rkeithhillRobert Holt
authored and
Robert Holt
committed
Allow debugging in interactive session with no dir change (#1397)
Fix #1330 This PR depends on a corresponding PR to PSES to have it handle null/empty string differently in the non-temp console case. For the generateLaunchConfig case, we now pass "" as cwd to PSES. That tells PSES to not change the directory *if* we aren't running in a temp console. If we are in a temp console, then use old logic to set working dir. Update "PowerShell Interactive Session" debug config to tell PSES to not change the working dir. Remove "program" field from launch config. This has been marked deprecated for over a year now. Change refs in ${workspaceRoot} to ${workpaceFolder} to work better in a multi-workspace environment. Remove unused imports/field in DebugSession.ts.
1 parent 2050d84 commit a0ee7a1

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

Diff for: package.json

+7-11
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@
262262
"type": "PowerShell",
263263
"request": "launch",
264264
"name": "PowerShell Launch ${Script}",
265-
"script": "^\"\\${workspaceRoot}/${Script}\"",
265+
"script": "^\"\\${workspaceFolder}/${Script}\"",
266266
"args": [],
267-
"cwd": "^\"\\${workspaceRoot}\""
267+
"cwd": "^\"\\${workspaceFolder}\""
268268
}
269269
},
270270
{
@@ -276,7 +276,7 @@
276276
"name": "PowerShell Pester Tests",
277277
"script": "Invoke-Pester",
278278
"args": [],
279-
"cwd": "^\"\\${workspaceRoot}\""
279+
"cwd": "^\"\\${workspaceFolder}\""
280280
}
281281
},
282282
{
@@ -297,17 +297,13 @@
297297
"type": "PowerShell",
298298
"request": "launch",
299299
"name": "PowerShell Interactive Session",
300-
"cwd": "^\"\\${workspaceRoot}\""
300+
"cwd": ""
301301
}
302302
}
303303
],
304304
"configurationAttributes": {
305305
"launch": {
306306
"properties": {
307-
"program": {
308-
"type": "string",
309-
"description": "Deprecated. Please use the 'script' property instead to specify the absolute path to the PowerShell script to launch under the debugger."
310-
},
311307
"script": {
312308
"type": "string",
313309
"description": "Optional: Absolute path to the PowerShell script to launch under the debugger."
@@ -322,8 +318,8 @@
322318
},
323319
"cwd": {
324320
"type": "string",
325-
"description": "Absolute path to the working directory. Default is the current workspace.",
326-
"default": "${workspaceRoot}"
321+
"description": "Absolute path to the working directory. Default is the current workspace folder.",
322+
"default": "${workspaceFolder}"
327323
},
328324
"createTemporaryIntegratedConsole": {
329325
"type": "boolean",
@@ -390,7 +386,7 @@
390386
"type": "PowerShell",
391387
"request": "launch",
392388
"name": "PowerShell Interactive Session",
393-
"cwd": "${workspaceRoot}"
389+
"cwd": ""
394390
}
395391
]
396392
}

Diff for: src/features/DebugSession.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import { hostname } from "os";
6-
import { dirname } from "path";
75
import vscode = require("vscode");
86
import { CancellationToken, DebugConfiguration, DebugConfigurationProvider,
97
ExtensionContext, ProviderResult, WorkspaceFolder } from "vscode";
10-
import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient";
8+
import { LanguageClient, RequestType } from "vscode-languageclient";
119
import { IFeature } from "../feature";
12-
import { getPlatformDetails, IPlatformDetails, OperatingSystem } from "../platform";
10+
import { getPlatformDetails, OperatingSystem } from "../platform";
1311
import { PowerShellProcess} from "../process";
1412
import { SessionManager } from "../session";
1513
import Settings = require("../settings");
@@ -19,7 +17,6 @@ export class DebugSessionFeature implements IFeature, DebugConfigurationProvider
1917

2018
private sessionCount: number = 1;
2119
private command: vscode.Disposable;
22-
private examplesPath: string;
2320
private tempDebugProcess: PowerShellProcess;
2421

2522
constructor(context: ExtensionContext, private sessionManager: SessionManager) {
@@ -75,12 +72,18 @@ export class DebugSessionFeature implements IFeature, DebugConfigurationProvider
7572
? currentDocument.uri.toString()
7673
: currentDocument.fileName;
7774

78-
// For a folder-less workspace, vscode.workspace.rootPath will be undefined.
79-
// PSES will convert that undefined to a reasonable working dir.
80-
config.cwd =
81-
currentDocument.isUntitled
82-
? vscode.workspace.rootPath
83-
: currentDocument.fileName;
75+
if (settings.debugging.createTemporaryIntegratedConsole) {
76+
// For a folder-less workspace, vscode.workspace.rootPath will be undefined.
77+
// PSES will convert that undefined to a reasonable working dir.
78+
config.cwd =
79+
currentDocument.isUntitled
80+
? vscode.workspace.rootPath
81+
: currentDocument.fileName;
82+
83+
} else {
84+
// If the non-temp integrated console is being used, default to the current working dir.
85+
config.cwd = "";
86+
}
8487
}
8588

8689
if (config.request === "launch") {

0 commit comments

Comments
 (0)