diff --git a/src/features/Console.ts b/src/features/Console.ts index 70ae72a7a8..cd06a4e9ea 100644 --- a/src/features/Console.ts +++ b/src/features/Console.ts @@ -7,6 +7,7 @@ import { LanguageClient, NotificationType, RequestType } from "vscode-languagecl import { ICheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/checkboxQuickPick"; import { IFeature } from "../feature"; import { Logger } from "../logging"; +import Settings = require("../settings"); export const EvaluateRequestType = new RequestType("evaluate"); export const OutputNotificationType = new NotificationType("output"); @@ -210,6 +211,20 @@ export class ConsoleFeature implements IFeature { return; } + if (vscode.window.activeTerminal && + vscode.window.activeTerminal.name !== "PowerShell Integrated Console") { + this.log.write("PSIC is not active terminal. Running in active terminal using 'runSelectedText'"); + await vscode.commands.executeCommand("workbench.action.terminal.runSelectedText"); + + // We need to honor the focusConsoleOnExecute setting here too. However, the boolean that `show` + // takes is called `preserveFocus` which when `true` the terminal will not take focus. + // This is the inverse of focusConsoleOnExecute so we have to inverse the boolean. + vscode.window.activeTerminal.show(!Settings.load().integratedConsole.focusConsoleOnExecute); + await vscode.commands.executeCommand("workbench.action.terminal.scrollToBottom"); + + return; + } + const editor = vscode.window.activeTextEditor; let selectionRange: vscode.Range;