-
Notifications
You must be signed in to change notification settings - Fork 513
Implementation of additional exe paths #1270
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import { | |
getPlatformDetails, IPlatformDetails, OperatingSystem } from "./platform"; | ||
|
||
export enum SessionStatus { | ||
NeverStarted, | ||
NotStarted, | ||
Initializing, | ||
Running, | ||
|
@@ -40,7 +41,7 @@ export class SessionManager implements Middleware { | |
private hostVersion: string; | ||
private editorServicesArgs: string; | ||
private powerShellExePath: string = ""; | ||
private sessionStatus: SessionStatus; | ||
private sessionStatus: SessionStatus = SessionStatus.NeverStarted; | ||
private suppressRestartPrompt: boolean; | ||
private focusConsoleOnExecute: boolean; | ||
private platformDetails: IPlatformDetails; | ||
|
@@ -246,6 +247,7 @@ export class SessionManager implements Middleware { | |
} | ||
|
||
public getPowerShellExePath(): string { | ||
let powerShellExePath: string; | ||
|
||
if (!this.sessionSettings.powerShellExePath && | ||
this.sessionSettings.developer.powerShellExePath) { | ||
|
@@ -280,11 +282,27 @@ export class SessionManager implements Middleware { | |
}); | ||
} | ||
|
||
// If powershell.powerShellDefaultVersion specified, attempt to find the PowerShell exe path | ||
// of the version specified by the setting. | ||
if ((this.sessionStatus === SessionStatus.NeverStarted) && this.sessionSettings.powerShellDefaultVersion) { | ||
const powerShellExePaths = getAvailablePowerShellExes(this.platformDetails, this.sessionSettings); | ||
const powerShellDefaultVersion = | ||
powerShellExePaths.find((item) => item.versionName === this.sessionSettings.powerShellDefaultVersion); | ||
|
||
if (powerShellDefaultVersion) { | ||
powerShellExePath = powerShellDefaultVersion.exePath; | ||
} else { | ||
this.log.writeWarning( | ||
`Could not find powerShellDefaultVersion: '${this.sessionSettings.powerShellDefaultVersion}'`); | ||
} | ||
} | ||
|
||
// Is there a setting override for the PowerShell path? | ||
let powerShellExePath = | ||
(this.sessionSettings.powerShellExePath || | ||
this.sessionSettings.developer.powerShellExePath || | ||
"").trim(); | ||
powerShellExePath = | ||
(powerShellExePath || | ||
this.sessionSettings.powerShellExePath || | ||
this.sessionSettings.developer.powerShellExePath || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is for backcompat? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming it's a fallback? Should the developer path come before the other one, or is the intent to need to blank out the normal path to get the dev one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah back in the day it was called Keith, I totally agree v2 should remove this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I "think" the only change I made was to use the value of |
||
"").trim(); | ||
|
||
// New versions of PS Core uninstall the previous version | ||
// so make sure the path stored in the settings exists. | ||
|
@@ -718,12 +736,25 @@ export class SessionManager implements Middleware { | |
private showSessionMenu() { | ||
let menuItems: SessionMenuItem[] = []; | ||
|
||
const currentExePath = (this.powerShellExePath || "").toLowerCase(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is SUPER nitpicky (I'm sorry) but is there a reason this line comes before the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries. I could move it below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahhh I see it below now. No need to change it. |
||
const availablePowerShellExes = | ||
getAvailablePowerShellExes(this.platformDetails, this.sessionSettings); | ||
|
||
if (this.sessionStatus === SessionStatus.Running) { | ||
const currentPowerShellExe = | ||
availablePowerShellExes | ||
.find((item) => item.exePath.toLowerCase() === currentExePath); | ||
|
||
const powerShellSessionName = | ||
currentPowerShellExe ? | ||
currentPowerShellExe.versionName : | ||
`PowerShell ${this.versionDetails.displayVersion} ` + | ||
`(${this.versionDetails.architecture}) ${this.versionDetails.edition} Edition ` + | ||
`[${this.versionDetails.version}]`; | ||
|
||
menuItems = [ | ||
new SessionMenuItem( | ||
`Current session: PowerShell ${this.versionDetails.displayVersion} ` + | ||
`(${this.versionDetails.architecture}) ${this.versionDetails.edition} Edition ` + | ||
`[${this.versionDetails.version}]`, | ||
`Current session: ${powerShellSessionName}`, | ||
() => { vscode.commands.executeCommand("PowerShell.ShowLogs"); }), | ||
|
||
new SessionMenuItem( | ||
|
@@ -738,9 +769,8 @@ export class SessionManager implements Middleware { | |
]; | ||
} | ||
|
||
const currentExePath = (this.powerShellExePath || "").toLowerCase(); | ||
const powerShellItems = | ||
getAvailablePowerShellExes(this.platformDetails) | ||
availablePowerShellExes | ||
.filter((item) => item.exePath.toLowerCase() !== currentExePath) | ||
.map((item) => { | ||
return new SessionMenuItem( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm going crazy but where is
getAvailablePowerShellExes
defined? I see it's inplatform.ts
but not itsession.ts
. How is being called here?I trust it works, but I'm just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's imported from platform.ts on line 25.