diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index f26f121a87d..1ed78327aa5 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -941,6 +941,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I }, createTerminal(nameOrOptions?: vscode.TerminalOptions | vscode.ExtensionTerminalOptions | string, shellPath?: string, shellArgs?: readonly string[] | string): vscode.Terminal { if (typeof nameOrOptions === 'object') { + if ('titleTemplate' in nameOrOptions && nameOrOptions.titleTemplate !== undefined) { + checkProposedApiEnabled(extension, 'terminalTitle'); + } if ('pty' in nameOrOptions) { return extHostTerminalService.createExtensionTerminal(nameOrOptions); } diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index 4dcec3f6681..52becdb9649 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -29,6 +29,7 @@ import { MarshalledId } from '../../../base/common/marshallingIds.js'; import { ISerializedTerminalInstanceContext } from '../../contrib/terminal/common/terminal.js'; import { isWindows } from '../../../base/common/platform.js'; import { hasKey } from '../../../base/common/types.js'; +import { checkProposedApiEnabled } from '../../services/extensions/common/extensions.js'; export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, IDisposable { @@ -425,7 +426,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I private readonly _bufferer: TerminalDataBufferer; private readonly _linkProviders: Set = new Set(); private readonly _completionProviders: Map> = new Map(); - private readonly _profileProviders: Map = new Map(); + private readonly _profileProviders: Map = new Map(); private readonly _quickFixProviders: Map = new Map(); private readonly _terminalLinkCache: Map> = new Map(); private readonly _terminalLinkCancellationSource: Map = new Map(); @@ -752,7 +753,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I if (this._profileProviders.has(id)) { throw new Error(`Terminal profile provider "${id}" already registered`); } - this._profileProviders.set(id, provider); + this._profileProviders.set(id, { provider, extension }); this._proxy.$registerProfileProvider(id, extension.identifier.value); return new VSCodeDisposable(() => { this._profileProviders.delete(id); @@ -845,7 +846,11 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I public async $createContributedProfileTerminal(id: string, options: ICreateContributedTerminalProfileOptions): Promise { const token = new CancellationTokenSource().token; - let profile = await this._profileProviders.get(id)?.provideTerminalProfile(token); + const profileProviderData = this._profileProviders.get(id); + if (!profileProviderData) { + throw new Error(`No terminal profile provider registered for id "${id}"`); + } + let profile = await profileProviderData.provider.provideTerminalProfile(token); if (token.isCancellationRequested) { return; } @@ -857,6 +862,10 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I throw new Error(`No terminal profile options provided for id "${id}"`); } + if (profile.options.titleTemplate !== undefined) { + checkProposedApiEnabled(profileProviderData.extension, 'terminalTitle'); + } + const profileOptions = options.titleTemplate && !profile.options.titleTemplate ? { ...profile.options, titleTemplate: options.titleTemplate } : profile.options;