Skip to content

Commit 3eb7d42

Browse files
null check on activeTerminal to workaround vscode behavior (#2141) (#2178)
* null check on activeTerminal * newline for linting
1 parent b2a5fe4 commit 3eb7d42

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/features/Console.ts

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { LanguageClient, NotificationType, RequestType } from "vscode-languagecl
77
import { ICheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/checkboxQuickPick";
88
import { IFeature } from "../feature";
99
import { Logger } from "../logging";
10+
import Settings = require("../settings");
1011

1112
export const EvaluateRequestType = new RequestType<IEvaluateRequestArguments, void, void, void>("evaluate");
1213
export const OutputNotificationType = new NotificationType<IOutputNotificationBody, void>("output");
@@ -210,6 +211,20 @@ export class ConsoleFeature implements IFeature {
210211
return;
211212
}
212213

214+
if (vscode.window.activeTerminal &&
215+
vscode.window.activeTerminal.name !== "PowerShell Integrated Console") {
216+
this.log.write("PSIC is not active terminal. Running in active terminal using 'runSelectedText'");
217+
await vscode.commands.executeCommand("workbench.action.terminal.runSelectedText");
218+
219+
// We need to honor the focusConsoleOnExecute setting here too. However, the boolean that `show`
220+
// takes is called `preserveFocus` which when `true` the terminal will not take focus.
221+
// This is the inverse of focusConsoleOnExecute so we have to inverse the boolean.
222+
vscode.window.activeTerminal.show(!Settings.load().integratedConsole.focusConsoleOnExecute);
223+
await vscode.commands.executeCommand("workbench.action.terminal.scrollToBottom");
224+
225+
return;
226+
}
227+
213228
const editor = vscode.window.activeTextEditor;
214229
let selectionRange: vscode.Range;
215230

0 commit comments

Comments
 (0)