Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,13 +941,15 @@ 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');
let options = nameOrOptions;
if (!isProposedApiEnabled(extension, 'terminalTitle') && 'titleTemplate' in nameOrOptions && nameOrOptions.titleTemplate !== undefined) {
console.error(`[${extension.identifier.value}] \`titleTemplate\` was provided to window.createTerminal but is ignored because the \`terminalTitle\` proposed API is not enabled.`);
options = { ...nameOrOptions, titleTemplate: undefined };
}
if ('pty' in nameOrOptions) {
return extHostTerminalService.createExtensionTerminal(nameOrOptions);
if ('pty' in options) {
return extHostTerminalService.createExtensionTerminal(options);
}
return extHostTerminalService.createTerminalFromOptions(nameOrOptions);
return extHostTerminalService.createTerminalFromOptions(options);
}
return extHostTerminalService.createTerminal(nameOrOptions, shellPath, shellArgs);
},
Expand Down
15 changes: 11 additions & 4 deletions src/vs/workbench/api/common/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +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';
import { isProposedApiEnabled } from '../../services/extensions/common/extensions.js';

export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, IDisposable {

Expand Down Expand Up @@ -862,11 +862,18 @@ 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 hasTerminalTitleProposal = isProposedApiEnabled(profileProviderData.extension, 'terminalTitle');
if (!hasTerminalTitleProposal && profile.options.titleTemplate !== undefined) {
console.error(`[${profileProviderData.extension.identifier.value}] \`titleTemplate\` returned from TerminalProfileProvider is ignored because the \`terminalTitle\` proposed API is not enabled.`);
profile = { options: { ...profile.options, titleTemplate: undefined } };
}
// options.titleTemplate is not explicitly stripped here because the profileOptions
// assignment below only applies it when hasTerminalTitleProposal is true.
if (!hasTerminalTitleProposal && options.titleTemplate !== undefined) {
console.error(`[${profileProviderData.extension.identifier.value}] \`titleTemplate\` passed to createContributedTerminalProfile is ignored because the \`terminalTitle\` proposed API is not enabled.`);
}

const profileOptions = options.titleTemplate && !profile.options.titleTemplate
const profileOptions = hasTerminalTitleProposal && options.titleTemplate && !profile.options.titleTemplate
? { ...profile.options, titleTemplate: options.titleTemplate }
: profile.options;

Expand Down
Loading