Skip to content

Commit

Permalink
Apply @andyleejordan Review Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinGrote committed Nov 22, 2024
1 parent ab06afd commit 0b4595c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
24 changes: 4 additions & 20 deletions pwsh-extension-dev.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"ms-azure-devops.azure-pipelines",
"ms-dotnettools.csharp",
"ms-vscode.powershell",
"hbenl.vscode-mocha-test-adapter",
Expand All @@ -31,7 +30,6 @@
"files.insertFinalNewline": true,
"files.associations": {
"**/snippets/*.json": "jsonc", // Use JSONC instead of JSON because that's how VS Code interprets snippet files, and it enables better source documentation.
"**/.vsts-ci/**/*.yml": "azure-pipelines",
},
// Ignore the Markdown rule:
"markdownlint.config": {
Expand Down Expand Up @@ -307,20 +305,6 @@
"group": "Test",
"order": 3
}
},
{
"name": "Interactively Test Rename",
"configurations": [
"Launch Extension - Rename Test Cases",
"Attach to Editor Services"
],
"preLaunchTask": "Build",
"stopAll": true,
"presentation": {
"hidden": false,
"group": "Test",
"order": 4
}
}
],
"configurations": [
Expand Down Expand Up @@ -379,7 +363,7 @@
"<node_internals>/**",
"**/node_modules/**",
"**/.vscode-test/**",
"**/app/out/vs/**" //Skips Extension Host internals
"**/app/out/vs/**", // Skips Extension Host internals
],
"presentation": {
"hidden": true
Expand Down Expand Up @@ -422,7 +406,6 @@
"name": "Attach to Editor Services",
"type": "coreclr",
"request": "attach",
// Waits for the extension terminal to become available and gets the PID, saves having to enter it manually.
"processId": "${command:PowerShell.PickPSHostProcess}",
"justMyCode": true,
"suppressJITOptimizations": true,
Expand Down Expand Up @@ -483,10 +466,11 @@
"skipFiles": [
"<node_internals>/**",
"**/node_modules/**",
"**/.vscode-test/**"
"**/.vscode-test/**" // Skips Extension Host internals
],
"presentation": {
"hidden": true, }
"hidden": true,
}
},
]
}
Expand Down
10 changes: 7 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
}

/** Registers a command that waits for PSES Activation and returns the PID, used to auto-attach the PSES debugger */
function registerWaitForPsesActivationCommand(context: vscode.ExtensionContext) {
function registerWaitForPsesActivationCommand(context: vscode.ExtensionContext): vscode.Disposable {
return vscode.commands.registerCommand(
"PowerShell.WaitForPsesActivationAndReturnProcessId",
async () => {
Expand All @@ -208,11 +208,15 @@ function registerWaitForPsesActivationCommand(context: vscode.ExtensionContext)
const pid = parseInt(pidContent.toString(), 10);
try {
// Check if the process is still alive, delete the PID file if not and continue waiting.
process.kill(pid, 0);
// https://nodejs.org/api/process.html#process_process_kill_pid_signal
// "As a special case, a signal of 0 can be used to test for the existence of a process. "
const NODE_TEST_PROCESS_EXISTENCE = 0

Check failure on line 213 in src/extension.ts

View workflow job for this annotation

GitHub Actions / node (macos-latest)

Missing semicolon

Check failure on line 213 in src/extension.ts

View workflow job for this annotation

GitHub Actions / node (ubuntu-latest)

Missing semicolon
process.kill(pid, NODE_TEST_PROCESS_EXISTENCE);
} catch {
await fs.delete(pidFile);
continue;
}
// VSCode command returns for launch configurations *must* be string type explicitly, will error on number or otherwise.
return pidContent.toString();
} catch {
// File doesn't exist yet, wait and try again
Expand All @@ -223,7 +227,7 @@ function registerWaitForPsesActivationCommand(context: vscode.ExtensionContext)
);
}

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

0 comments on commit 0b4595c

Please sign in to comment.