-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Add PS Core in select default shell on windows#72425 #72689
Changes from 8 commits
1c483b1
edff6f4
0f119a2
029f329
f96955a
8778906
8e465d0
2ffd468
9f0d0bd
f50f83d
60dc18d
4d96541
7c0151a
ffcb9e6
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 |
---|---|---|
|
@@ -117,7 +117,30 @@ export class TerminalService extends BrowserTerminalService implements ITerminal | |
}); | ||
} | ||
|
||
private _detectWindowsShells(): Promise<IQuickPickItem[]> { | ||
/** | ||
* Get the executable file path of shell from registry. | ||
* @param Registry The data of imported from `vscode-windows-registry` | ||
* @param shellName The shell name to get the executable file path | ||
* @returns The executable file path of shell or `'ShellNotFound'` | ||
*/ | ||
private _getShellPathFromRegistry(Registry: typeof import('vscode-windows-registry'), shellName: string): string { | ||
const shellNotFound = 'ShellNotFound'; | ||
let shellPath; | ||
|
||
try { | ||
shellPath = Registry.GetStringRegKey('HKEY_LOCAL_MACHINE', `SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\${shellName}.exe`, ''); | ||
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 could be simplified:
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.
Thanks. 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 realized that using sorry for the trouble! |
||
} catch (e) { | ||
shellPath = shellNotFound; | ||
} | ||
|
||
if (shellPath === undefined) { | ||
shellPath = shellNotFound; | ||
} | ||
|
||
return shellPath; | ||
} | ||
|
||
private async _detectWindowsShells(): Promise<IQuickPickItem[]> { | ||
// Determine the correct System32 path. We want to point to Sysnative | ||
// when the 32-bit version of VS Code is running on a 64-bit machine. | ||
// The reason for this is because PowerShell's important PSReadline | ||
|
@@ -131,9 +154,12 @@ export class TerminalService extends BrowserTerminalService implements ITerminal | |
useWSLexe = true; | ||
} | ||
|
||
const Registry = await import('vscode-windows-registry'); | ||
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. Let's move the await into |
||
|
||
const expectedLocations = { | ||
'Command Prompt': [`${system32Path}\\cmd.exe`], | ||
PowerShell: [`${system32Path}\\WindowsPowerShell\\v1.0\\powershell.exe`], | ||
'PowerShell Core': [this._getShellPathFromRegistry(Registry, 'pwsh')], | ||
'WSL Bash': [`${system32Path}\\${useWSLexe ? 'wsl.exe' : 'bash.exe'}`], | ||
'Git Bash': [ | ||
`${process.env['ProgramW6432']}\\Git\\bin\\bash.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 this function should be a little more targetted to just pwsh for now and then return either
[]
or[ 'path' ]