diff --git a/package.json b/package.json index f65cde26af..015eaedcd2 100644 --- a/package.json +++ b/package.json @@ -1043,6 +1043,11 @@ "default": false, "markdownDescription": "Do not show the startup banner in the PowerShell Extension Terminal." }, + "powershell.suppressTerminalStoppedNotification": { + "type": "boolean", + "default": false, + "markdownDescription": "Do not show a notification when the PowerShell Extension Terminal has stopped." + }, "powershell.integratedConsole.showOnStartup": { "type": "boolean", "default": true, diff --git a/src/session.ts b/src/session.ts index b5b201a601..2908f6d27f 100644 --- a/src/session.ts +++ b/src/session.ts @@ -980,7 +980,8 @@ export class SessionManager implements Middleware { return { action: CloseAction.DoNotRestart, message: - "Connection to PowerShell Editor Services (the Extension Terminal) was closed. See below prompt to restart!", + "Connection to PowerShell Editor Services (the Extension Terminal) was closed.", + handled: true, }; }, }, @@ -1158,6 +1159,16 @@ Type 'help' to get help. } private async promptForRestart(): Promise { + // Check user configuration before showing notification + const suppressNotification = + vscode.workspace + .getConfiguration("powershell") + .get("suppressTerminalStoppedNotification") ?? false; + + if (suppressNotification) { + return; + } + await this.logger.writeAndShowErrorWithActions( "The PowerShell Extension Terminal has stopped, would you like to restart it? IntelliSense and other features will not work without it!", [ @@ -1171,6 +1182,17 @@ Type 'help' to get help. prompt: "No", action: undefined, }, + { + prompt: "Don't Show Again", + action: async (): Promise => { + await changeSetting( + "suppressTerminalStoppedNotification", + true, + true, + this.logger, + ); + }, + }, ], ); }