You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Workspace Setting for Integrated Console PS Version #2099
I work different projects, some require WinPS5 due to library dependencies, some use PS6+. Currently the integrated terminal that is used appears to be a "global" setting. If I switch it to PS6+ in one project and then open the other, it stays PS6+, this leads to annoying toggle back and forth.
I want to be able to set so that when I open a certain project or workspace, it remembers what integrated terminal version I was using for that workspace
User/Workspace setting for powershell.integratedterminalversion that would match the string in the session picker dropdown, e.g. "Powershell", "Windows Powershell (x64)", "Powershell Preview", etc.
Thanks for opening this feature request Justin Grote (@JustinGrote)! I was looking through other issues and was wondering if you feel that #190 addresses the same concerns as you?
That issue is from a really long time ago before multi-root workspaces were
a native thing in VSCode, so I'd say not exactly, it just needs to be a
setting to change which version of powershell the integrated console starts
with, and it needs to be respected both as a user setting and a workspace
setting.
On Tue, Jul 23, 2019 at 2:29 PM Sydney Smith ***@***.***> wrote:
Thanks for opening this feature request @JustinGrote
<https://github.com/JustinGrote>! I was looking through other issues and
was wondering if you feel that #190
<#190> addresses
the same concerns as you?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2099?email_source=notifications&email_token=ADUNKURGHZVUY3E3YPIU4DTQA5Z4NA5CNFSM4IGGZ532YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2UPYNY#issuecomment-514391095>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADUNKUWRTBPGKYMMKMHLDODQA5Z4NANCNFSM4IGGZ53Q>
.
TylerLeonhardt my problems are likely related to #1586. I did some more extensive testing and found the following (using powershell-preview extension):
powershell.powershellexepath gets populated immediately if you toggle shell from the lower right menu (or use Show Session Menu)
It does not update if you specify a powershell.powershelldefaultversion and reload window.
Killing the terminal after the reload reverts to this powershell.powershellexepath that was previously saved in (because it was never updated)
For instance if you set powershelldefaultversion to "Powershell Preview" (added via AdditionalExePaths) but your last shell was "Windows Powershell (x64)", then PS Preview will load on reload, but if you kill the terminal via the trash icon and restart it, it comes back as "Windows Powershell (x64)"
Fix
Make it so that when the extension finds the selection via powershell.powershelldefaultversion, it immediately sets the settings.json "placeholder" in the same way that the session selection menu does.
Alternatively, make a kill/reload of the terminal window follow the same discovery process as "first launch" and not just go with whatever powershellexepath is set to.
Side bug
If you set powershellexepath as a workspace setting, it doesn't get updated, so it is "sticky" and even if you toggle to another console it keeps coming back to whatever is set in workspace setting. This kind of meets my criteria, except I can't toggle to another version of powershell quickly without commenting it out if I want to test xplat compatability or something.
That aside, it does seem to work on a workspace-level as long as I don't kill the window, so if the above bug is fixed I think we are good to go and can close this.
EDIT: I can record a screengif of the behavior if you can't repro. Thanks!
This will basically do the behavior I described above, and then whatever you set powershell.powershellDefaultVersion to will be sticky to that project, and stay that way if you terminal and reload a session. You can set a global user setting, as well as a per-workspace override, and it works fine. If you decide to switch session mid-session, will still be fine.
You will get a nag message on startup if it had to switch runtimes that the runtime had switched and ask if you want to restart it, just ignore it.
Justin Grote (@JustinGrote) thanks for providing all this info and proposed work around...we just discussed this and the possible ramification and are worried that this would cause unexpected behavior when choosing a version from the session menu...you are correct though in that we need to make a fix to ensure that the default version specified in the settings is being used for any session not started by the session menu
We no longer depend on powerShellExePath first for anything
TylerLeonhardt I don't think this statement is accurate at least with the Nov 1st Powershell Preview, were his changes incorporated in that release?
Whenever you switch shells with the lower right or the session menu command, it updates PS Exe Path at the usersettings level, and that seems to always override whatever I might have defined.
I also did the following tests with the following session menu for reference:
Remove powershellExePath and PowershellDefaultVersion at both user and workspace level. Get this prompt, ignore it
Start terminal session, 5.1 (x64) comes up. powershellExePath still blank
Manually set PowershellDefaultVersion user setting to "Powershell Preview (x64)" and reload window.
Integrated terminal is still 5.1 x64, all settings still the same
Repeat with workspace, no dice.
Manually update powershellExePath and reload, it is now on Preview.
Blank out again
Try setting workspace PowershellDefaultVersion to "Windows Powershell (x64)"
Reload window, no effect.
Toggle it with session menu and reload window, it now works but that's because powershellExePath was populated.
Thanks for the details Justin Grote (@JustinGrote)! This sounds like a bug. We did the work to discover PowerShell exes but we still needed to hook that up to the session mention and some other inner stuff it seems...
Alright, I have a PR out to fix this bug by removing powerShellExePath from everything and showing a notification to help the user with the transition: #2099
Activity
[-][Feature] Workspace Setting for Integration Console PS Version[/-][+][Feature] Workspace Setting for Integrated Console PS Version[/+]SydneyhSmith commentedon Jul 23, 2019
Thanks for opening this feature request Justin Grote (@JustinGrote)! I was looking through other issues and was wondering if you feel that #190 addresses the same concerns as you?
JustinGrote commentedon Jul 24, 2019
TylerLeonhardt commentedon Jul 26, 2019
Justin Grote (@JustinGrote) is this the kind of setting you're looking for?
https://github.com/PowerShell/vscode-powershell/blob/master/package.json#L574-L576
JustinGrote commentedon Jul 26, 2019
TylerLeonhardt my problems are likely related to #1586. I did some more extensive testing and found the following (using powershell-preview extension):
For instance if you set powershelldefaultversion to "Powershell Preview" (added via AdditionalExePaths) but your last shell was "Windows Powershell (x64)", then PS Preview will load on reload, but if you kill the terminal via the trash icon and restart it, it comes back as "Windows Powershell (x64)"
Fix
Make it so that when the extension finds the selection via powershell.powershelldefaultversion, it immediately sets the settings.json "placeholder" in the same way that the session selection menu does.
Alternatively, make a kill/reload of the terminal window follow the same discovery process as "first launch" and not just go with whatever powershellexepath is set to.
Side bug
If you set powershellexepath as a workspace setting, it doesn't get updated, so it is "sticky" and even if you toggle to another console it keeps coming back to whatever is set in workspace setting. This kind of meets my criteria, except I can't toggle to another version of powershell quickly without commenting it out if I want to test xplat compatability or something.
That aside, it does seem to work on a workspace-level as long as I don't kill the window, so if the above bug is fixed I think we are good to go and can close this.
EDIT: I can record a screengif of the behavior if you can't repro. Thanks!
JustinGrote commentedon Jul 26, 2019
Workaround
Add this to your Microsoft.VSCode_profile.ps1
This will basically do the behavior I described above, and then whatever you set
powershell.powershellDefaultVersionto will be sticky to that project, and stay that way if you terminal and reload a session. You can set a global user setting, as well as a per-workspace override, and it works fine. If you decide to switch session mid-session, will still be fine.You will get a nag message on startup if it had to switch runtimes that the runtime had switched and ask if you want to restart it, just ignore it.
JustinGrote commentedon Jul 26, 2019
Recommended Fix
TylerLeonhardt There should be a call to changePowershellExePath here:
vscode-powershell/src/session.ts
Lines 293 to 295 in 0388343
SydneyhSmith commentedon Jul 26, 2019
Justin Grote (@JustinGrote) thanks for providing all this info and proposed work around...we just discussed this and the possible ramification and are worried that this would cause unexpected behavior when choosing a version from the session menu...you are correct though in that we need to make a fix to ensure that the default version specified in the settings is being used for any session not started by the session menu
9 remaining items
JustinGrote commentedon Nov 13, 2019
TylerLeonhardt I don't think this statement is accurate at least with the Nov 1st Powershell Preview, were his changes incorporated in that release?
Whenever you switch shells with the lower right or the session menu command, it updates PS Exe Path at the usersettings level, and that seems to always override whatever I might have defined.
I also did the following tests with the following session menu for reference:

Remove

powershellExePathandPowershellDefaultVersionat both user and workspace level. Get this prompt, ignore itStart terminal session, 5.1 (x64) comes up.
powershellExePathstill blankManually set PowershellDefaultVersion user setting to "Powershell Preview (x64)" and reload window.
Integrated terminal is still 5.1 x64, all settings still the same
Repeat with workspace, no dice.
Manually update
powershellExePathand reload, it is now on Preview.Blank out again
Try setting workspace
PowershellDefaultVersionto "Windows Powershell (x64)"Reload window, no effect.
Toggle it with session menu and reload window, it now works but that's because
powershellExePathwas populated.TylerLeonhardt commentedon Nov 13, 2019
Thanks for the details Justin Grote (@JustinGrote)! This sounds like a bug. We did the work to discover PowerShell exes but we still needed to hook that up to the session mention and some other inner stuff it seems...
TylerLeonhardt commentedon Nov 14, 2019
Alright, I have a PR out to fix this bug by removing powerShellExePath from everything and showing a notification to help the user with the transition:
#2099
JustinGrote commentedon Nov 14, 2019
TylerLeonhardt I think you meant #2304