Skip to content

Commit aca8ca3

Browse files
committed
Add temporaryConsoleWindowActionOnDebugEnd option
Adds a new option `temporaryConsoleWindowActionOnDebugEnd` to both the attach and launch configurations which can be used to specify what happens with the temporary integrated console when a debug session ends. The option can be set to `keep`, current behaviour and default, that will keep the active terminal as the temporary console. It can be set to `close` which closes the terminal and removes it from the selection pane or `hide` which keeps the terminal window alive but changes the active terminal to the previous one before the debug session started.
1 parent 4cea222 commit aca8ca3

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,21 @@
581581
"type": "string",
582582
"description": "If you would like to use a custom coreclr attach debug launch configuration for the debug session, specify the name here. Otherwise a default basic config will be used. The config must be a coreclr attach config. Launch configs are not supported.",
583583
"default": false
584+
},
585+
"temporaryConsoleWindowActionOnDebugEnd": {
586+
"type": "string",
587+
"description": "Determines whether the temporary PowerShell Extension Terminal is closed when the debugging session ends.",
588+
"default": "keep",
589+
"enum": [
590+
"close",
591+
"hide",
592+
"keep"
593+
],
594+
"enumDescriptions": [
595+
"Closes the temporary PowerShell Extension Terminal when the debugging session ends.",
596+
"Hides the temporary PowerShell Extension Terminal when the debugging session ends and restores the previous window before the debug session had started. This does nothing if the previous window was closed during the debug session.",
597+
"Keeps the temporary PowerShell Extension Terminal open after the debugging session ends."
598+
]
584599
}
585600
}
586601
},
@@ -615,6 +630,21 @@
615630
"type": "boolean",
616631
"description": "Determines whether a temporary PowerShell Extension Terminal is created for each debugging session, useful for debugging PowerShell classes and binary modules. Overrides the user setting 'powershell.debugging.createTemporaryIntegratedConsole'.",
617632
"default": false
633+
},
634+
"temporaryConsoleWindowActionOnDebugEnd": {
635+
"type": "string",
636+
"description": "Determines whether the temporary PowerShell Extension Terminal is closed when the debugging session ends.",
637+
"default": "keep",
638+
"enum": [
639+
"close",
640+
"hide",
641+
"keep"
642+
],
643+
"enumDescriptions": [
644+
"Closes the temporary PowerShell Extension Terminal when the debugging session ends.",
645+
"Hides the temporary PowerShell Extension Terminal when the debugging session ends and restores the previous window before the debug session had started. This does nothing if the previous window was closed during the debug session.",
646+
"Keeps the temporary PowerShell Extension Terminal open after the debugging session ends."
647+
]
618648
}
619649
}
620650
}

src/features/DebugSession.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ export class DebugSessionFeature
466466
return this.resolveAttachDotnetDebugConfiguration(config);
467467
}
468468

469+
config.temporaryConsoleWindowActionOnDebugEnd ??= "keep";
470+
469471
return config;
470472
}
471473

@@ -498,6 +500,8 @@ export class DebugSessionFeature
498500
session: DebugSession,
499501
): Promise<IEditorServicesSessionDetails | undefined> {
500502
const settings = getSettings();
503+
const previousActiveTerminal = window.activeTerminal;
504+
501505
this.tempDebugProcess =
502506
await this.sessionManager.createDebugSessionProcess(
503507
settings,
@@ -600,6 +604,23 @@ export class DebugSessionFeature
600604
);
601605
}
602606

607+
const closeDebugEvent = debug.onDidTerminateDebugSession(
608+
(terminatedSession) => {
609+
closeDebugEvent.dispose();
610+
611+
if (terminatedSession.id !== session.id) {
612+
return;
613+
}
614+
615+
if (terminatedSession.configuration.temporaryConsoleWindowActionOnDebugEnd === "close") {
616+
this.tempDebugProcess?.dispose();
617+
} else if (terminatedSession.configuration.temporaryConsoleWindowActionOnDebugEnd === "hide" &&
618+
window.terminals.includes(previousActiveTerminal)) {
619+
previousActiveTerminal.show();
620+
}
621+
},
622+
);
623+
603624
return this.tempSessionDetails;
604625
}
605626

@@ -705,6 +726,8 @@ export class DebugSessionFeature
705726
}
706727
}
707728

729+
config.temporaryConsoleWindowActionOnDebugEnd ??= "keep";
730+
708731
return config;
709732
}
710733

0 commit comments

Comments
 (0)