Skip to content

Add temporaryConsoleWindowActionOnDebugEnd option #5255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,21 @@
"type": "string",
"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.",
"default": false
},
"temporaryConsoleWindowActionOnDebugEnd": {
"type": "string",
"description": "Determines whether the temporary PowerShell Extension Terminal is closed when the debugging session ends.",
"default": "keep",
"enum": [
"close",
"hide",
"keep"
],
"enumDescriptions": [
"Closes the temporary PowerShell Extension Terminal when the debugging session ends.",
"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.",
"Keeps the temporary PowerShell Extension Terminal open after the debugging session ends."
]
}
}
},
Expand Down Expand Up @@ -615,6 +630,21 @@
"type": "boolean",
"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'.",
"default": false
},
"temporaryConsoleWindowActionOnDebugEnd": {
"type": "string",
"description": "Determines whether the temporary PowerShell Extension Terminal is closed when the debugging session ends.",
"default": "keep",
"enum": [
"close",
"hide",
"keep"
],
"enumDescriptions": [
"Closes the temporary PowerShell Extension Terminal when the debugging session ends.",
"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.",
"Keeps the temporary PowerShell Extension Terminal open after the debugging session ends."
]
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions src/features/DebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ export class DebugSessionFeature
return this.resolveAttachDotnetDebugConfiguration(config);
}

config.temporaryConsoleWindowActionOnDebugEnd ??= "keep";

return config;
}

Expand Down Expand Up @@ -498,6 +500,8 @@ export class DebugSessionFeature
session: DebugSession,
): Promise<IEditorServicesSessionDetails | undefined> {
const settings = getSettings();
const previousActiveTerminal = window.activeTerminal;

this.tempDebugProcess =
await this.sessionManager.createDebugSessionProcess(
settings,
Expand Down Expand Up @@ -600,6 +604,36 @@ export class DebugSessionFeature
);
}

if (
session.configuration.temporaryConsoleWindowActionOnDebugEnd !==
"keep"
) {
const closeDebugEvent = debug.onDidTerminateDebugSession(
(terminatedSession) => {
closeDebugEvent.dispose();

if (terminatedSession.id !== session.id) {
return;
}

if (
terminatedSession.configuration
.temporaryConsoleWindowActionOnDebugEnd === "close"
) {
this.tempDebugProcess?.dispose();
} else if (
terminatedSession.configuration
.temporaryConsoleWindowActionOnDebugEnd ===
"hide" &&
previousActiveTerminal &&
window.terminals.includes(previousActiveTerminal)
) {
previousActiveTerminal.show();
}
},
);
}

return this.tempSessionDetails;
}

Expand Down Expand Up @@ -705,6 +739,8 @@ export class DebugSessionFeature
}
}

config.temporaryConsoleWindowActionOnDebugEnd ??= "keep";

return config;
}

Expand Down
Loading