MCPcopy
hub / github.com/PowerShell/vscode-powershell / createDebugSessionProcess

Method createDebugSessionProcess

src/session.ts:443–497  ·  view source on GitHub ↗
(
        settings: Settings,
        powershellExeName?: string,
    )

Source from the content-addressed store, hash-verified

441 }
442
443 public async createDebugSessionProcess(
444 settings: Settings,
445 powershellExeName?: string,
446 ): Promise<PowerShellProcess> {
447 // NOTE: We only support one temporary Extension Terminal at a time. To
448 // support more, we need to track each separately, and tie the session
449 // for the event handler to the right process (and dispose of the event
450 // handler when the process is disposed).
451 this.debugSessionProcess?.dispose();
452 this.debugEventHandler?.dispose();
453 if (this.PowerShellExeDetails === undefined) {
454 return Promise.reject(
455 new Error("Required PowerShellExeDetails undefined!"),
456 );
457 }
458
459 const debugPowerShellExeDetails =
460 powershellExeName === undefined
461 ? this.PowerShellExeDetails
462 : ((await this.findPowerShell(powershellExeName)) ??
463 this.PowerShellExeDetails);
464
465 // TODO: It might not be totally necessary to update the session
466 // settings here, but I don't want to accidentally change this behavior
467 // just yet. Working on getting things to be more idempotent!
468 this.sessionSettings = settings;
469
470 const bundledModulesPath = await this.getBundledModulesPath();
471 this.debugSessionProcess = new PowerShellProcess(
472 debugPowerShellExeDetails.exePath,
473 bundledModulesPath,
474 true,
475 false,
476 this.logger,
477 this.extensionContext.logUri,
478 this.getEditorServicesArgs(
479 bundledModulesPath,
480 this.PowerShellExeDetails,
481 ) + "-DebugServiceOnly ",
482 this.getNewSessionFilePath(),
483 this.sessionSettings,
484 );
485
486 // Similar to the regular Extension Terminal, we need to send a key
487 // press to the process spawned for temporary Extension Terminals when
488 // the server requests a cancellation os Console.ReadKey.
489 this.debugEventHandler =
490 vscode.debug.onDidReceiveDebugSessionCustomEvent((e) => {
491 if (e.event === "powerShell/sendKeyPress") {
492 this.debugSessionProcess?.sendKeyPress();
493 }
494 });
495
496 return this.debugSessionProcess;
497 }
498
499 public async waitUntilStarted(): Promise<void> {
500 while (this.sessionStatus !== SessionStatus.Running) {

Callers 1

Calls 6

findPowerShellMethod · 0.95
getBundledModulesPathMethod · 0.95
getEditorServicesArgsMethod · 0.95
getNewSessionFilePathMethod · 0.95
sendKeyPressMethod · 0.80
disposeMethod · 0.45

Tested by

no test coverage detected