Change getDefaultShellAndArgs to use promises

Part of #75793
This commit is contained in:
Daniel Imms
2020-02-05 12:03:45 -08:00
parent 1aefcce704
commit 5fad95f544
7 changed files with 14 additions and 13 deletions

View File

@@ -309,15 +309,16 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
return true;
}
private async _onRequestAvailableShells(callback: IAvailableShellsRequest): Promise<void> {
private async _onRequestAvailableShells(req: IAvailableShellsRequest): Promise<void> {
if (this._isPrimaryExtHost()) {
callback(await this._proxy.$getAvailableShells());
req.callback(await this._proxy.$getAvailableShells());
}
}
private _onRequestDefaultShellAndArgs(request: IDefaultShellAndArgsRequest): void {
private async _onRequestDefaultShellAndArgs(req: IDefaultShellAndArgsRequest): Promise<void> {
if (this._isPrimaryExtHost()) {
this._proxy.$requestDefaultShellAndArgs(request.useAutomationShell).then(e => request.callback(e.shell, e.args));
const res = await this._proxy.$getDefaultShellAndArgs(req.useAutomationShell);
req.callback(res.shell, res.args);
}
}

View File

@@ -1288,7 +1288,7 @@ export interface ExtHostTerminalServiceShape {
$acceptProcessRequestLatency(id: number): number;
$acceptWorkspacePermissionsChanged(isAllowed: boolean): void;
$getAvailableShells(): Promise<IShellDefinitionDto[]>;
$requestDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto>;
$getDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto>;
}
export interface ExtHostSCMShape {

View File

@@ -326,7 +326,7 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
public abstract getDefaultShellArgs(useAutomationShell: boolean, configProvider: ExtHostConfigProvider): string[] | string;
public abstract $spawnExtHostProcess(id: number, shellLaunchConfigDto: IShellLaunchConfigDto, activeWorkspaceRootUriComponents: UriComponents, cols: number, rows: number, isWorkspaceShellAllowed: boolean): Promise<void>;
public abstract $getAvailableShells(): Promise<IShellDefinitionDto[]>;
public abstract $requestDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto>;
public abstract $getDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto>;
public abstract $acceptWorkspacePermissionsChanged(isAllowed: boolean): void;
public createExtensionTerminal(options: vscode.ExtensionTerminalOptions): vscode.Terminal {
@@ -610,7 +610,7 @@ export class WorkerExtHostTerminalService extends BaseExtHostTerminalService {
throw new Error('Not implemented');
}
public async $requestDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto> {
public async $getDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto> {
throw new Error('Not implemented');
}

View File

@@ -179,7 +179,7 @@ export class ExtHostTask extends ExtHostTaskBase {
}
public $getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }> {
return this._terminalService.$requestDefaultShellAndArgs(true);
return this._terminalService.$getDefaultShellAndArgs(true);
}
public async $jsonTasksSupported(): Promise<boolean> {

View File

@@ -204,12 +204,12 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
return detectAvailableShells();
}
public async $requestDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto> {
public async $getDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto> {
const configProvider = await this._extHostConfiguration.getConfigProvider();
return Promise.resolve({
return {
shell: this.getDefaultShell(useAutomationShell, configProvider),
args: this.getDefaultShellArgs(useAutomationShell, configProvider)
});
};
}
public $acceptWorkspacePermissionsChanged(isAllowed: boolean): void {