提交 5fad95f5 编写于 作者: D Daniel Imms

Change getDefaultShellAndArgs to use promises

Part of #75793
上级 1aefcce7
...@@ -309,15 +309,16 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape ...@@ -309,15 +309,16 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
return true; return true;
} }
private async _onRequestAvailableShells(callback: IAvailableShellsRequest): Promise<void> { private async _onRequestAvailableShells(req: IAvailableShellsRequest): Promise<void> {
if (this._isPrimaryExtHost()) { 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()) { 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);
} }
} }
......
...@@ -1288,7 +1288,7 @@ export interface ExtHostTerminalServiceShape { ...@@ -1288,7 +1288,7 @@ export interface ExtHostTerminalServiceShape {
$acceptProcessRequestLatency(id: number): number; $acceptProcessRequestLatency(id: number): number;
$acceptWorkspacePermissionsChanged(isAllowed: boolean): void; $acceptWorkspacePermissionsChanged(isAllowed: boolean): void;
$getAvailableShells(): Promise<IShellDefinitionDto[]>; $getAvailableShells(): Promise<IShellDefinitionDto[]>;
$requestDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto>; $getDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto>;
} }
export interface ExtHostSCMShape { export interface ExtHostSCMShape {
......
...@@ -326,7 +326,7 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ ...@@ -326,7 +326,7 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
public abstract getDefaultShellArgs(useAutomationShell: boolean, configProvider: ExtHostConfigProvider): string[] | string; 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 $spawnExtHostProcess(id: number, shellLaunchConfigDto: IShellLaunchConfigDto, activeWorkspaceRootUriComponents: UriComponents, cols: number, rows: number, isWorkspaceShellAllowed: boolean): Promise<void>;
public abstract $getAvailableShells(): Promise<IShellDefinitionDto[]>; 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 abstract $acceptWorkspacePermissionsChanged(isAllowed: boolean): void;
public createExtensionTerminal(options: vscode.ExtensionTerminalOptions): vscode.Terminal { public createExtensionTerminal(options: vscode.ExtensionTerminalOptions): vscode.Terminal {
...@@ -610,7 +610,7 @@ export class WorkerExtHostTerminalService extends BaseExtHostTerminalService { ...@@ -610,7 +610,7 @@ export class WorkerExtHostTerminalService extends BaseExtHostTerminalService {
throw new Error('Not implemented'); throw new Error('Not implemented');
} }
public async $requestDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto> { public async $getDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto> {
throw new Error('Not implemented'); throw new Error('Not implemented');
} }
......
...@@ -179,7 +179,7 @@ export class ExtHostTask extends ExtHostTaskBase { ...@@ -179,7 +179,7 @@ export class ExtHostTask extends ExtHostTaskBase {
} }
public $getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }> { public $getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }> {
return this._terminalService.$requestDefaultShellAndArgs(true); return this._terminalService.$getDefaultShellAndArgs(true);
} }
public async $jsonTasksSupported(): Promise<boolean> { public async $jsonTasksSupported(): Promise<boolean> {
......
...@@ -204,12 +204,12 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService { ...@@ -204,12 +204,12 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
return detectAvailableShells(); return detectAvailableShells();
} }
public async $requestDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto> { public async $getDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto> {
const configProvider = await this._extHostConfiguration.getConfigProvider(); const configProvider = await this._extHostConfiguration.getConfigProvider();
return Promise.resolve({ return {
shell: this.getDefaultShell(useAutomationShell, configProvider), shell: this.getDefaultShell(useAutomationShell, configProvider),
args: this.getDefaultShellArgs(useAutomationShell, configProvider) args: this.getDefaultShellArgs(useAutomationShell, configProvider)
}); };
} }
public $acceptWorkspacePermissionsChanged(isAllowed: boolean): void { public $acceptWorkspacePermissionsChanged(isAllowed: boolean): void {
......
...@@ -600,7 +600,7 @@ export class TerminalService implements ITerminalService { ...@@ -600,7 +600,7 @@ export class TerminalService implements ITerminalService {
} }
private _detectWindowsShells(): Promise<IShellDefinition[]> { private _detectWindowsShells(): Promise<IShellDefinition[]> {
return new Promise(r => this._onRequestAvailableShells.fire(r)); return new Promise(r => this._onRequestAvailableShells.fire({ callback: r }));
} }
......
...@@ -360,7 +360,7 @@ export interface IStartExtensionTerminalRequest { ...@@ -360,7 +360,7 @@ export interface IStartExtensionTerminalRequest {
} }
export interface IAvailableShellsRequest { export interface IAvailableShellsRequest {
(shells: IShellDefinition[]): void; callback: (shells: IShellDefinition[]) => void;
} }
export interface IDefaultShellAndArgsRequest { export interface IDefaultShellAndArgsRequest {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册