diff --git a/src/features/DebugSession.ts b/src/features/DebugSession.ts index e9cc0db3ab..e10bbd78e1 100644 --- a/src/features/DebugSession.ts +++ b/src/features/DebugSession.ts @@ -225,8 +225,9 @@ export class DebugSessionFeature extends LanguageClientConsumer if (this.sessionManager.getSessionStatus() !== SessionStatus.Running) { await this.sessionManager.start(); } - // Create or show the Extension Terminal. - vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true); + + // Create or show the debug terminal (either temporary or session). + this.sessionManager.showDebugTerminal(true); return config; } diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index ec48743183..7cda274f1a 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -3,6 +3,7 @@ import * as path from "path"; import vscode = require("vscode"); +import { SessionManager } from "../session"; import Settings = require("../settings"); import utils = require("../utils"); @@ -16,7 +17,7 @@ export class PesterTestsFeature implements vscode.Disposable { private command: vscode.Disposable; private invokePesterStubScriptPath: string; - constructor() { + constructor(private sessionManager: SessionManager) { this.invokePesterStubScriptPath = path.resolve(__dirname, "../modules/PowerShellEditorServices/InvokePesterStub.ps1"); // File context-menu command - Run Pester Tests @@ -126,7 +127,7 @@ export class PesterTestsFeature implements vscode.Disposable { private async launch(launchConfig: vscode.DebugConfiguration): Promise { // Create or show the interactive console // TODO: #367 Check if "newSession" mode is configured - await vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true); + this.sessionManager.showDebugTerminal(true); // TODO: Update to handle multiple root workspaces. // diff --git a/src/features/RunCode.ts b/src/features/RunCode.ts index 83f8c78473..db1a8546b3 100644 --- a/src/features/RunCode.ts +++ b/src/features/RunCode.ts @@ -1,11 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import * as path from "path"; import vscode = require("vscode"); import { SessionManager } from "../session"; import Settings = require("../settings"); -import utils = require("../utils"); enum LaunchType { Debug, @@ -41,7 +39,7 @@ export class RunCodeFeature implements vscode.Disposable { private async launch(launchConfig: string | vscode.DebugConfiguration) { // Create or show the interactive console // TODO: #367: Check if "newSession" mode is configured - await vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true); + this.sessionManager.showDebugTerminal(true); // TODO: Update to handle multiple root workspaces. await vscode.debug.startDebugging(vscode.workspace.workspaceFolders?.[0], launchConfig); diff --git a/src/main.ts b/src/main.ts index eaccd6e405..c35e92cc60 100644 --- a/src/main.ts +++ b/src/main.ts @@ -139,7 +139,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { await this.showSessionMenu(); }), vscode.workspace.onDidChangeConfiguration(async () => { await this.onConfigurationUpdated(); }), vscode.commands.registerCommand( - "PowerShell.ShowSessionConsole", (isExecute?: boolean) => { this.showSessionConsole(isExecute); }), + "PowerShell.ShowSessionConsole", (isExecute?: boolean) => { this.showSessionTerminal(isExecute); }), vscode.commands.registerCommand( "PowerShell.WalkthroughTelemetry", (satisfaction: number) => { this.sendTelemetryEvent("powershellWalkthroughSatisfaction", null, { level: satisfaction }); @@ -795,12 +795,20 @@ Type 'help' to get help. await this.restartSession(exePath.displayName); } - private showSessionConsole(isExecute?: boolean) { - if (this.languageServerProcess) { - this.languageServerProcess.showConsole(isExecute && !this.focusConsoleOnExecute); + // Shows the temp debug terminal if it exists, otherwise the session terminal. + public showDebugTerminal(isExecute?: boolean) { + if (this.debugSessionProcess) { + this.debugSessionProcess.showTerminal(isExecute && !this.focusTerminalOnExecute); + } else { + this.languageServerProcess?.showTerminal(isExecute && !this.focusTerminalOnExecute) } } + // Always shows the session terminal. + public showSessionTerminal(isExecute?: boolean) { + this.languageServerProcess?.showTerminal(isExecute && !this.focusTerminalOnExecute); + } + private async showSessionMenu() { const availablePowerShellExes = await this.powershellExeFinder.getAllAvailablePowerShellInstallations();