Skip to content
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

Handle Persistent Terminal Sessions #80

Merged
merged 1 commit into from
Jul 22, 2024
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
2 changes: 1 addition & 1 deletion vscode/powershellprotools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "powershellprotools",
"displayName": "PowerShell Pro Tools",
"description": "Powerful extensions for PowerShell development.",
"version": "2024.7.4",
"version": "2024.7.5",
"publisher": "ironmansoftware",
"repository": {
"type": "git",
Expand Down
23 changes: 21 additions & 2 deletions vscode/powershellprotools/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { convertToUdElement } from './commands/convertToUdElement';
import { profile, clearProfiling } from './commands/profile';
import { showWinFormDesigner } from './commands/formsDesigner';
import { generateWinForm } from './commands/generateWinForm';
import { PowerShellService } from './services/powershellservice';
import { PowerShellService, SessionStatus } from './services/powershellservice';
import { Container } from './container';
import { showDataGrid } from './commands/showDataGrid';
import { statusBarItemMenu } from './commands/statusBarItemMenu';
Expand Down Expand Up @@ -48,7 +48,7 @@ export interface IPowerShellExtensionClient {


export async function activate(context: vscode.ExtensionContext) {
powerShellService = new PowerShellService(context);
var service = powerShellService = new PowerShellService(context);
context.subscriptions.push(showDataGrid(context));
context.subscriptions.push(packageAsExe());
context.subscriptions.push(convertToUdElement());
Expand All @@ -72,6 +72,25 @@ export async function activate(context: vscode.ExtensionContext) {
return;
}

const configuration: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("terminal.integrated");
var persistentSessions = configuration.get<boolean>("enablePersistentSessions");
if (persistentSessions) {
var result = await vscode.window.showErrorMessage("PowerShell Pro Tools requires the terminal.integrated.enablePersistentSessions setting to be disabled.", "Disable", "Learn About Persistent Sessions");
if (result == "Learn About Persistent Sessions") {
vscode.env.openExternal(vscode.Uri.parse("https://code.visualstudio.com/docs/terminal/advanced#_persistent-sessions"));
}
else if (result == "Disable") {
await configuration.update("enablePersistentSessions", false, true);
vscode.window.showInformationMessage("Persistent sessions have been disabled. Please reload the window for the changes to take effect.");
}
else {
vscode.window.showErrorMessage("PowerShell Pro Tools did not start because Persistent Terminal Sessions is enabled.");
service.setSessionStatus(SessionStatus.Disabled);
}

return;
}

if (!extension.isActive) {
await extension.activate();
const powerShellExtensionClient = extension!.exports as IPowerShellExtensionClient;
Expand Down
9 changes: 7 additions & 2 deletions vscode/powershellprotools/src/services/powershellservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const fs = require('fs');
export enum SessionStatus {
Initializing,
Failed,
Connected
Connected,
Disabled
}

export class PowerShellService {
Expand Down Expand Up @@ -59,7 +60,7 @@ export class PowerShellService {
this.setSessionStatus(SessionStatus.Initializing);
}

private setSessionStatus(status: SessionStatus): void {
setSessionStatus(status: SessionStatus): void {
// Set color and icon for 'Running' by default
let statusIconText = "$(sync) PowerShell Pro Tools";
let statusColor = "#f3fc74";
Expand All @@ -73,6 +74,10 @@ export class PowerShellService {
statusIconText = "$(alert) PowerShell Pro Tools";
statusColor = "#fcc174";
toolTip = "PowerShell Pro Tools failed to connect. Check out the Output channel for PowerShell Pro Tools for more information.";
} else if (status === SessionStatus.Disabled) {
statusIconText = "$(circle-slash) PowerShell Pro Tools";
statusColor = "#fcc174";
toolTip = "PowerShell Pro Tools is disabled because Persistent Terminal Sessions is enabled. Please disable Persistent Terminal Sessions and reload the window.";
}

this.statusBarItem.color = statusColor;
Expand Down
Loading