Skip to content

Commit d611a44

Browse files
committed
Apply @andyleejordan Review Suggestions
1 parent ab06afd commit d611a44

File tree

4 files changed

+17
-29
lines changed

4 files changed

+17
-29
lines changed

docs/development.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ Explore the `vscode-powershell.build.ps1` file for other build targets.
5959
First, ensure you have completed a build as instructed above, as the launch templates do not check some prerequisites for performance reasons.
6060

6161
To debug the extension use one of the provided `Launch Extension` debug configurations.
62-
1. `Launch Extension`: Launches the debugger using your personal profile settings
63-
1. `Temp Profile`: Launches VSCode with an ephemeral temp profile that resets on every launch. Useful for "out of the box" environment testing.
64-
1. `Isolated Profile`: Launches the debugger with a persistent debug profile specific to the extension, so you can preserve some settings or test certain prerequisites.
62+
1. `Launch Extension`: Launches the debugger using your personal profile settings.
63+
2. `Temp Profile`: Launches VS Code with a temp profile that resets on every launch. Useful for "out of the box" environment testing.
64+
3. `Isolated Profile`: Launches the debugger with a persistent debug profile specific to the extension, so you can preserve some settings or test certain prerequisites.
6565

6666
All three templates use pre-launch tasks to build the code, and support automatic restart of the extension host on changes to the Extension source code. [Hot Reload](https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/) is also enabled for PowerShell Editor Services.
6767

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,12 @@
302302
"icon": "$(layout-panel-right)"
303303
},
304304
{
305-
"title": "[PowerShell Debug Input Task] Wait for and return PSES startup process ID",
305+
"title": "[PowerShell Debug Input Task] Wait for and return PSES startup PID",
306306
"command": "PowerShell.WaitForPsesActivationAndReturnProcessId",
307307
"enablement": "false"
308308
},
309309
{
310-
"title": "[PowerShell Debug Input Task] Get the VSCode Session ID for writing the PID file",
310+
"title": "[PowerShell Debug Input Task] Get the VS Code Session ID for writing the PID file",
311311
"command": "GetVsCodeSessionId",
312312
"enablement": "false"
313313
}

pwsh-extension-dev.code-workspace

+4-20
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"davidanson.vscode-markdownlint",
1616
"dbaeumer.vscode-eslint",
1717
"editorconfig.editorconfig",
18-
"ms-azure-devops.azure-pipelines",
1918
"ms-dotnettools.csharp",
2019
"ms-vscode.powershell",
2120
"hbenl.vscode-mocha-test-adapter",
@@ -31,7 +30,6 @@
3130
"files.insertFinalNewline": true,
3231
"files.associations": {
3332
"**/snippets/*.json": "jsonc", // Use JSONC instead of JSON because that's how VS Code interprets snippet files, and it enables better source documentation.
34-
"**/.vsts-ci/**/*.yml": "azure-pipelines",
3533
},
3634
// Ignore the Markdown rule:
3735
"markdownlint.config": {
@@ -307,20 +305,6 @@
307305
"group": "Test",
308306
"order": 3
309307
}
310-
},
311-
{
312-
"name": "Interactively Test Rename",
313-
"configurations": [
314-
"Launch Extension - Rename Test Cases",
315-
"Attach to Editor Services"
316-
],
317-
"preLaunchTask": "Build",
318-
"stopAll": true,
319-
"presentation": {
320-
"hidden": false,
321-
"group": "Test",
322-
"order": 4
323-
}
324308
}
325309
],
326310
"configurations": [
@@ -379,7 +363,7 @@
379363
"<node_internals>/**",
380364
"**/node_modules/**",
381365
"**/.vscode-test/**",
382-
"**/app/out/vs/**" //Skips Extension Host internals
366+
"**/app/out/vs/**", // Skips Extension Host internals
383367
],
384368
"presentation": {
385369
"hidden": true
@@ -422,7 +406,6 @@
422406
"name": "Attach to Editor Services",
423407
"type": "coreclr",
424408
"request": "attach",
425-
// Waits for the extension terminal to become available and gets the PID, saves having to enter it manually.
426409
"processId": "${command:PowerShell.PickPSHostProcess}",
427410
"justMyCode": true,
428411
"suppressJITOptimizations": true,
@@ -483,10 +466,11 @@
483466
"skipFiles": [
484467
"<node_internals>/**",
485468
"**/node_modules/**",
486-
"**/.vscode-test/**"
469+
"**/.vscode-test/**" // Skips Extension Host internals
487470
],
488471
"presentation": {
489-
"hidden": true, }
472+
"hidden": true,
473+
}
490474
},
491475
]
492476
}

src/extension.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
158158
"GetVsCodeSessionId",
159159
() => vscode.env.sessionId
160160
),
161-
// Register a command that waits for the Externsion Terminal to be active. Can be used by .NET Attach Tasks
161+
// Register a command that waits for the Extension Terminal to be active. Can be used by .NET Attach Tasks.
162162
registerWaitForPsesActivationCommand(context)
163163
];
164164

@@ -193,7 +193,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
193193
}
194194

195195
/** Registers a command that waits for PSES Activation and returns the PID, used to auto-attach the PSES debugger */
196-
function registerWaitForPsesActivationCommand(context: vscode.ExtensionContext) {
196+
function registerWaitForPsesActivationCommand(context: vscode.ExtensionContext): vscode.Disposable {
197197
return vscode.commands.registerCommand(
198198
"PowerShell.WaitForPsesActivationAndReturnProcessId",
199199
async () => {
@@ -208,11 +208,15 @@ function registerWaitForPsesActivationCommand(context: vscode.ExtensionContext)
208208
const pid = parseInt(pidContent.toString(), 10);
209209
try {
210210
// Check if the process is still alive, delete the PID file if not and continue waiting.
211-
process.kill(pid, 0);
211+
// https://nodejs.org/api/process.html#process_process_kill_pid_signal
212+
// "As a special case, a signal of 0 can be used to test for the existence of a process. "
213+
const NODE_TEST_PROCESS_EXISTENCE = 0
214+
process.kill(pid, NODE_TEST_PROCESS_EXISTENCE);
212215
} catch {
213216
await fs.delete(pidFile);
214217
continue;
215218
}
219+
// VSCode command returns for launch configurations *must* be string type explicitly, will error on number or otherwise.
216220
return pidContent.toString();
217221
} catch {
218222
// File doesn't exist yet, wait and try again
@@ -223,7 +227,7 @@ function registerWaitForPsesActivationCommand(context: vscode.ExtensionContext)
223227
);
224228
}
225229

226-
/** Restarts the extension host when extension file changes are detected. Useful for development.. */
230+
/** Restarts the extension host when extension file changes are detected. Useful for development. */
227231
function restartOnExtensionFileChanges(context: vscode.ExtensionContext): void {
228232
const watcher = vscode.workspace.createFileSystemWatcher(
229233
new vscode.RelativePattern(context.extensionPath, "dist/*.js")

0 commit comments

Comments
 (0)