Make PowerShell 7 default if available and show in choose shell menu (#112768)

* make PowerShell 7 default if available and show in choose shell menu

* misc feedback

* better handle ARM and use pfs everywhere also update pfs to handle AppExecLinks

* fix test

* move to async

* add logging

* powershell global tool is in the image apparently

* have path test be the same

* try/catch the readlink

* await exists

* fix test

* check what arch node is

* fix indexes

* address daniel's feedback

* have getProgramFilesPath return null instead
This commit is contained in:
Tyler James Leonhardt
2021-01-11 15:38:03 -08:00
committed by GitHub
parent 74038b7e0d
commit 732d4ff89e
11 changed files with 500 additions and 49 deletions

View File

@@ -24,7 +24,7 @@ import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { MergedEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariableCollection';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { withNullAsUndefined } from 'vs/base/common/types';
import { getSystemShell } from 'vs/base/node/shell';
import { getSystemShell, getSystemShellSync } from 'vs/base/node/shell';
import { generateUuid } from 'vs/base/common/uuid';
export class ExtHostTerminalService extends BaseExtHostTerminalService {
@@ -34,6 +34,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
// TODO: Pull this from main side
private _isWorkspaceShellAllowed: boolean = false;
private _defaultShell: string | undefined;
constructor(
@IExtHostRpcService extHostRpc: IExtHostRpcService,
@@ -44,6 +45,12 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
@IExtHostInitDataService private _extHostInitDataService: IExtHostInitDataService
) {
super(true, extHostRpc);
// Getting the SystemShell is an async operation, however, the ExtHost terminal service is mostly synchronous
// and the API `vscode.env.shell` is also synchronous. The default shell _should_ be set when extensions are
// starting up but if not, we run getSystemShellSync below which gets a sane default.
getSystemShell(platform.platform).then(s => this._defaultShell = s);
this._updateLastActiveWorkspace();
this._updateVariableResolver();
this._registerListeners();
@@ -78,10 +85,11 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
.inspect<string | string[]>(key.substr(key.lastIndexOf('.') + 1));
return this._apiInspectConfigToPlain<string | string[]>(setting);
};
return terminalEnvironment.getDefaultShell(
fetchSetting,
this._isWorkspaceShellAllowed,
getSystemShell(platform.platform),
this._defaultShell ?? getSystemShellSync(platform.platform),
process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'),
process.env.windir,
terminalEnvironment.createVariableResolver(this._lastActiveWorkspace, this._variableResolver),