Skip to content

Commit de60d8e

Browse files
committed
Fix variable closure issue in PS Core session menu items
This change fixes an issue with variable closures in the PowerShell Core items of the session menu. The use of `var` instead of `let` caused the last item in the list of PowerShell Core items to always be used no matter which of those items was selected.
1 parent 8817257 commit de60d8e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/session.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -734,12 +734,16 @@ export class SessionManager {
734734

735735
var pscorePaths = this.getPowerShellCorePaths();
736736
for (var pscorePath of pscorePaths) {
737-
var pscoreVersion = path.parse(pscorePath).base;
738-
var pscoreExePath = path.join(pscorePath, "powershell.exe");
739-
var pscoreItem = new SessionMenuItem(
737+
let pscoreVersion = path.parse(pscorePath).base;
738+
let pscoreExePath = path.join(pscorePath, "powershell.exe");
739+
let pscoreItem = new SessionMenuItem(
740740
`Switch to PowerShell Core ${pscoreVersion}`,
741-
() => { this.restartSession({
742-
type: SessionType.UsePath, path: pscoreExePath, isWindowsDevBuild: false })
741+
() => {
742+
this.restartSession({
743+
type: SessionType.UsePath,
744+
path: pscoreExePath,
745+
isWindowsDevBuild: false
746+
})
743747
});
744748

745749
menuItems.push(pscoreItem);

0 commit comments

Comments
 (0)