From b3d93459d77de0f5c38be4565b45fdec758e4d2a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 9 Jun 2021 07:36:00 -0700 Subject: [PATCH] Terminal profile contribution feedback Part of #120369 --- src/vs/vscode.proposed.d.ts | 18 ++++++++++++++++-- .../api/common/extHostTerminalService.ts | 10 +++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 472e6340889..ec68a958961 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -903,12 +903,26 @@ declare module 'vscode' { export function registerTerminalProfileProvider(id: string, provider: TerminalProfileProvider): Disposable; } + /** + * Provides a terminal profile for the contributed terminal profile when launched via the UI or + * command. + */ export interface TerminalProfileProvider { /** - * Provide terminal profile options for the requested terminal. + * Provide the terminal profile. * @param token A cancellation token that indicates the result is no longer needed. */ - provideProfileOptions(token: CancellationToken): ProviderResult; + provideTerminalProfile(token: CancellationToken): ProviderResult; + } + + /** + * A terminal profile defines how a termianl will be launched. + */ + export interface TerminalProfile { + /** + * The options that the terminal will launch with. + */ + options: TerminalOptions | ExtensionTerminalOptions; } //#endregion diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index 23b91c7f505..3046587b253 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -598,18 +598,18 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I public async $createContributedProfileTerminal(id: string, isSplitTerminal: boolean): Promise { const token = new CancellationTokenSource().token; - const options = await this._profileProviders.get(id)?.provideProfileOptions(token); + const profile = await this._profileProviders.get(id)?.provideTerminalProfile(token); if (token.isCancellationRequested) { return; } - if (!options) { + if (!profile) { throw new Error(`No terminal profile options provided for id "${id}"`); } - if ('pty' in options) { - this.createExtensionTerminal(options, { isSplitTerminal }); + if ('pty' in profile.options) { + this.createExtensionTerminal(profile.options, { isSplitTerminal }); return; } - this.createTerminalFromOptions(options, { isSplitTerminal }); + this.createTerminalFromOptions(profile.options, { isSplitTerminal }); } public async $provideLinks(terminalId: number, line: string): Promise {