Skip to content

Use new isTransient API to prevent duplicate integrated consoles #3854

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

Merged
merged 1 commit into from
Mar 4, 2022
Merged
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
26 changes: 15 additions & 11 deletions src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Licensed under the MIT License.

import cp = require("child_process");
import fs = require("fs");
import net = require("net");
import os = require("os");
import * as semver from "semver";
import path = require("path");
import vscode = require("vscode");
import { Logger } from "./logging";
Expand Down Expand Up @@ -104,14 +102,20 @@ export class PowerShellProcess {
utils.deleteSessionFile(this.sessionFilePath);

// Launch PowerShell in the integrated terminal
this.consoleTerminal =
vscode.window.createTerminal({
name: this.title,
shellPath: this.exePath,
shellArgs: powerShellArgs,
hideFromUser: !this.sessionSettings.integratedConsole.showOnStartup,
cwd: this.sessionSettings.cwd
});
const terminalOptions: vscode.TerminalOptions = {
name: this.title,
shellPath: this.exePath,
shellArgs: powerShellArgs,
hideFromUser: !this.sessionSettings.integratedConsole.showOnStartup,
cwd: this.sessionSettings.cwd,
};

// This API is available only in newer versions of VS Code.
if (semver.gte(vscode.version, "1.65.0")) {
(terminalOptions as any).isTransient = true;
}

this.consoleTerminal = vscode.window.createTerminal(terminalOptions);

const pwshName = path.basename(this.exePath);
this.log.write(`${pwshName} started.`);
Expand Down
12 changes: 2 additions & 10 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ export class SessionManager implements Middleware {
case SessionStatus.Running:
case SessionStatus.NeverStarted:
case SessionStatus.NotStarted:
// This icon is available since 1.56, now our current engine version.
this.statusBarItem.text = "$(terminal-powershell)";
// These have to be reset because this function mutates state.
this.statusBarItem.color = undefined;
Expand All @@ -669,18 +668,11 @@ export class SessionManager implements Middleware {
case SessionStatus.Initializing:
case SessionStatus.Stopping:
this.statusBarItem.text = "$(sync)";
// The warning colors were added later than our current engine version.
// https://code.visualstudio.com/api/references/theme-color#status-bar-colors
this.statusBarItem.color = (semver.gte(vscode.version, "1.59.0"))
? new vscode.ThemeColor("statusBarItem.warningForeground")
: new vscode.ThemeColor("statusBarItem.errorForeground");
this.statusBarItem.backgroundColor = (semver.gte(vscode.version, "1.59.0"))
? new vscode.ThemeColor("statusBarItem.warningBackground")
: new vscode.ThemeColor("statusBarItem.errorBackground");
this.statusBarItem.color = new vscode.ThemeColor("statusBarItem.warningForeground");
this.statusBarItem.backgroundColor = new vscode.ThemeColor("statusBarItem.warningBackground");
break;
case SessionStatus.Failed:
this.statusBarItem.text = "$(alert)";
// The error colors have been available since 1.53.
this.statusBarItem.color = new vscode.ThemeColor("statusBarItem.errorForeground");
this.statusBarItem.backgroundColor = new vscode.ThemeColor("statusBarItem.errorBackground");
break;
Expand Down