-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Setting Powershell as default terminal for Windows 10+ (fixes #16838) #18493
Setting Powershell as default terminal for Windows 10+ (fixes #16838) #18493
Conversation
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.
Just a few comments, I restarted the Travis build as it looked like it was flaky.
import platform = require('vs/base/common/platform'); | ||
import processes = require('vs/base/node/processes'); | ||
|
||
const powershellPath = `${ process.env.SystemRoot }/system32/WindowsPowerShell/v1.0/powershell.exe`; |
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 sysnative/
should be used on 64 bit machines? Please confirm @daviwil
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.
That is correct. Since VS Code is a 32-bit process, the 64-bit version of PowerShell has to be explicitly launched otherwise you'll get the 32-bit version. Here's the relevant code from the PowerShell extension:
@@ -17,7 +17,7 @@ export const TERMINAL_SERVICE_ID = 'terminalService'; | |||
|
|||
export const TERMINAL_DEFAULT_SHELL_LINUX = !platform.isWindows ? (process.env.SHELL || 'sh') : 'sh'; | |||
export const TERMINAL_DEFAULT_SHELL_OSX = !platform.isWindows ? (process.env.SHELL || 'sh') : 'sh'; | |||
export const TERMINAL_DEFAULT_SHELL_WINDOWS = processes.getWindowsShell(); | |||
/** const TERMINAL_DEFAULT_SHELL_WINDOWS moved to ../electron-browser/terminal.ts */ |
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.
You can remove this line 👍
import processes = require('vs/base/node/processes'); | ||
|
||
const powershellPath = `${ process.env.SystemRoot }/system32/WindowsPowerShell/v1.0/powershell.exe`; | ||
const isAtLeastWindows10 = platform.isWindows && parseFloat(os.release()) >= 10; |
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 you'd be better off getting the major version here as os.release()
may return x.y.z
?
Something like this should be safe (if Node does indeed give that format):
parseInt(os.release().split('.')[0], 10) >= 10
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'm not sure if it's necessary, since I'm parsing it to a float. That means 10.2.22222 and 11.4.4444 will still be >= 10 (and 9.5.555 will not).
I'm happy to take the change - let me know what you want to do.
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 it would be best to be explicit here, parseFloat('10.2.22222')
may work but it feelss dodgy to me and the behavior itself may even be undefined and only works by coincidence.
Thanks for sending this out, @jchadwick! |
… 32-bit Easter egg: this commit was done via the VSCode PS shell!
33cb4c7
to
74aee4a
Compare
@Tyriar I think that I incorporated all your feedback. Not sure what's going on with the Travis build, but I think I'm all good here. |
import processes = require('vs/base/node/processes'); | ||
|
||
const powerShellExePath = | ||
!process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432') |
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.
@daviwil so this is an env variable only available on 64 bit Windows? Would it be better to check process.arch
instead?
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 dunno, I just copied from the PowerShell extension. :-D
process.arch
probably makes more sense anyway. I'll change it.
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.
Actually, now that I'm playing around with it, process.arch
is going to give you 32-bit. I think that code that I stole from @daviwil is probably the right way to do it.
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.
Yep, that's what I had to use to figure out the true bitness of the OS.
Great, thanks @jchadwick 😄 |
Resolves #16838