diff --git a/src/vs/workbench/api/node/extHostCLIServer.ts b/src/vs/workbench/api/node/extHostCLIServer.ts index b3857616f70..ad9e9fe5933 100644 --- a/src/vs/workbench/api/node/extHostCLIServer.ts +++ b/src/vs/workbench/api/node/extHostCLIServer.ts @@ -15,7 +15,7 @@ import { ILogService } from 'vs/platform/log/common/log'; export interface OpenCommandPipeArgs { type: 'open'; fileURIs?: string[]; - folderURIs: string[]; + folderURIs?: string[]; forceNewWindow?: boolean; diffMode?: boolean; addMode?: boolean; @@ -24,6 +24,11 @@ export interface OpenCommandPipeArgs { waitMarkerFilePath?: string; } +export interface OpenExternalCommandPipeArgs { + type: 'openExternal'; + uris: string[]; +} + export interface StatusPipeArgs { type: 'status'; } @@ -34,6 +39,8 @@ export interface RunCommandPipeArgs { args: any[]; } +export type PipeCommand = OpenCommandPipeArgs | StatusPipeArgs | RunCommandPipeArgs | OpenExternalCommandPipeArgs; + export interface ICommandsExecuter { executeCommand(id: string, ...args: any[]): Promise; } @@ -73,11 +80,14 @@ export class CLIServerBase { req.setEncoding('utf8'); req.on('data', (d: string) => chunks.push(d)); req.on('end', () => { - const data: OpenCommandPipeArgs | StatusPipeArgs | RunCommandPipeArgs | any = JSON.parse(chunks.join('')); + const data: PipeCommand | any = JSON.parse(chunks.join('')); switch (data.type) { case 'open': this.open(data, res); break; + case 'openExternal': + this.openExternal(data, res); + break; case 'status': this.getStatus(data, res); break; @@ -133,6 +143,14 @@ export class CLIServerBase { res.end(); } + private openExternal(data: OpenExternalCommandPipeArgs, res: http.ServerResponse) { + for (const uri of data.uris) { + this._commands.executeCommand('_workbench.open', URI.parse(uri)); + } + res.writeHead(200); + res.end(); + } + private async getStatus(data: StatusPipeArgs, res: http.ServerResponse) { try { const status = await this._commands.executeCommand('_issues.getSystemStatus');