Skip to content

Commit

Permalink
Merge pull request #75883 from microsoft/alexr00/terminalPlatformOver…
Browse files Browse the repository at this point in the history
…ride

Add platform override to getDefaultShellAndArgs in terminal
  • Loading branch information
Tyriar authored Jun 24, 2019
2 parents cbb1c72 + 648b2d5 commit 460e72b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ export class TerminalTaskSystem implements ITaskSystem {
let terminalName = this.createTerminalName(task);
let originalCommand = task.command.name;
if (isShellCommand) {
const defaultConfig = await this.terminalInstanceService.getDefaultShellAndArgs();
const defaultConfig = await this.terminalInstanceService.getDefaultShellAndArgs(platform);
shellLaunchConfig = { name: terminalName, executable: defaultConfig.shell, args: defaultConfig.args, waitOnExit };
let shellSpecified: boolean = false;
let shellOptions: ShellConfiguration | undefined = task.command.options && task.command.options.shell;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { WebLinksAddon as XTermWebLinksAddon } from 'xterm-addon-web-links';
import { SearchAddon as XTermSearchAddon } from 'xterm-addon-search';
import { ITerminalInstance, IWindowsShellHelper, ITerminalConfigHelper, ITerminalChildProcess, IShellLaunchConfig, IDefaultShellAndArgsRequest } from 'vs/workbench/contrib/terminal/common/terminal';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { IProcessEnvironment, Platform } from 'vs/base/common/platform';
import { Event } from 'vs/base/common/event';

export const ITerminalInstanceService = createDecorator<ITerminalInstanceService>('terminalInstanceService');
Expand All @@ -30,7 +30,7 @@ export interface ITerminalInstanceService {
createWindowsShellHelper(shellProcessId: number, instance: ITerminalInstance, xterm: XTermTerminal): IWindowsShellHelper;
createTerminalProcess(shellLaunchConfig: IShellLaunchConfig, cwd: string, cols: number, rows: number, env: IProcessEnvironment, windowsEnableConpty: boolean): ITerminalChildProcess;

getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }>;
getDefaultShellAndArgs(platformOverride?: Platform): Promise<{ shell: string, args: string[] | string | undefined }>;
getMainProcessParentEnv(): Promise<IProcessEnvironment>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/
import { ITerminalInstance, IWindowsShellHelper, IShellLaunchConfig, ITerminalChildProcess, IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY } from 'vs/workbench/contrib/terminal/common/terminal';
import { WindowsShellHelper } from 'vs/workbench/contrib/terminal/node/windowsShellHelper';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IProcessEnvironment, isLinux, isMacintosh, isWindows, platform } from 'vs/base/common/platform';
import { IProcessEnvironment, isLinux, isMacintosh, isWindows, platform, Platform } from 'vs/base/common/platform';
import { TerminalProcess } from 'vs/workbench/contrib/terminal/node/terminalProcess';
import { getSystemShell } from 'vs/workbench/contrib/terminal/node/terminal';
import { Terminal as XTermTerminal } from 'xterm';
Expand Down Expand Up @@ -68,18 +68,20 @@ export class TerminalInstanceService implements ITerminalInstanceService {
return this._storageService.getBoolean(IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY, StorageScope.WORKSPACE, false);
}

public getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }> {
public getDefaultShellAndArgs(platformOverride: Platform = platform): Promise<{ shell: string, args: string[] | undefined }> {
const isWorkspaceShellAllowed = this._isWorkspaceShellAllowed();
const shell = getDefaultShell(
(key) => this._configurationService.inspect(key),
isWorkspaceShellAllowed,
getSystemShell(platform),
getSystemShell(platformOverride),
process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'),
process.env.windir
process.env.windir,
platformOverride
);
const args = getDefaultShellArgs(
(key) => this._configurationService.inspect(key),
isWorkspaceShellAllowed
isWorkspaceShellAllowed,
platformOverride
);
return Promise.resolve({ shell, args });
}
Expand Down

0 comments on commit 460e72b

Please sign in to comment.