diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index af9e4acda97..6eb760ba348 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -672,10 +672,14 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I public async $createContributedProfileTerminal(id: string, options: ICreateContributedTerminalProfileOptions): Promise { const token = new CancellationTokenSource().token; - const profile = await this._profileProviders.get(id)?.provideTerminalProfile(token); + let profile = await this._profileProviders.get(id)?.provideTerminalProfile(token); if (token.isCancellationRequested) { return; } + if (profile && !('options' in profile)) { + profile = { options: profile }; + } + if (!profile || !('options' in profile)) { throw new Error(`No terminal profile options provided for id "${id}"`); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts index 7397f11c1be..59a87e993e1 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts @@ -1444,7 +1444,7 @@ export function registerTerminalActions() { title: terminalStrings.split, f1: true, category, - precondition: TerminalContextKeys.processSupported, + precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.webExtensionContributedProfile), keybinding: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Digit5, weight: KeybindingWeight.WorkbenchContrib, @@ -1632,7 +1632,7 @@ export function registerTerminalActions() { title: { value: localize('workbench.action.terminal.new', "Create New Terminal"), original: 'Create New Terminal' }, f1: true, category, - precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported), + precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.webExtensionContributedProfile), icon: Codicon.plus, keybinding: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Backquote, @@ -1703,6 +1703,8 @@ export function registerTerminalActions() { } else { await terminalGroupService.showPanel(true); } + } else if (TerminalContextKeys.webExtensionContributedProfile) { + commandService.executeCommand(TerminalCommandId.NewWithProfile); } } }); @@ -2089,7 +2091,7 @@ export function refreshTerminalActions(detectedProfiles: ITerminalProfile[]) { title: { value: localize('workbench.action.terminal.newWithProfile', "Create New Terminal (With Profile)"), original: 'Create New Terminal (With Profile)' }, f1: true, category, - precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported), + precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.webExtensionContributedProfile), description: { description: 'workbench.action.terminal.newWithProfile', args: [{ @@ -2114,10 +2116,6 @@ export function refreshTerminalActions(detectedProfiles: ITerminalProfile[]) { const terminalService = accessor.get(ITerminalService); const terminalProfileService = accessor.get(ITerminalProfileService); - if (!terminalService.isProcessSupportRegistered) { - return; - } - const terminalGroupService = accessor.get(ITerminalGroupService); const workspaceContextService = accessor.get(IWorkspaceContextService); const commandService = accessor.get(ICommandService); diff --git a/src/vs/workbench/contrib/terminal/browser/terminalGroupService.ts b/src/vs/workbench/contrib/terminal/browser/terminalGroupService.ts index 05432965274..4f56bbebdee 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalGroupService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalGroupService.ts @@ -32,7 +32,6 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe } private _terminalGroupCountContextKey: IContextKey; - private _terminalCountContextKey: IContextKey; private _container: HTMLElement | undefined; @@ -70,10 +69,8 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe this.onDidDisposeGroup(group => this._removeGroup(group)); this._terminalGroupCountContextKey = TerminalContextKeys.groupCount.bindTo(this._contextKeyService); - this._terminalCountContextKey = TerminalContextKeys.count.bindTo(this._contextKeyService); this.onDidChangeGroups(() => this._terminalGroupCountContextKey.set(this.groups.length)); - this.onDidChangeInstances(() => this._terminalCountContextKey.set(this.instances.length)); this._findState = new FindReplaceState(); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts b/src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts index 324bef51c71..13cd17a6732 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts @@ -72,7 +72,7 @@ export class TerminalProfileService implements ITerminalProfileService { } }); this._webExtensionContributedProfileContextKey = TerminalContextKeys.webExtensionContributedProfile.bindTo(this._contextKeyService); - + this._updateWebContextKey(); this._primaryOffProcessTerminalService = !!this._environmentService.remoteAuthority ? this._remoteTerminalService : (this._localTerminalService || this._remoteTerminalService); // Wait up to 5 seconds for profiles to be ready so it's assured that we know the actual // default terminal before launching the first terminal. This isn't expected to ever take diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index 1af150af022..956360434b3 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -61,6 +61,8 @@ export class TerminalService implements ITerminalService { private _processSupportContextKey: IContextKey; private _terminalHasBeenCreated: IContextKey; + private _terminalCountContextKey: IContextKey; + private readonly _localTerminalService?: ILocalTerminalService; private readonly _primaryOffProcessTerminalService?: IOffProcessTerminalService; private _configHelper: TerminalConfigHelper; @@ -225,6 +227,7 @@ export class TerminalService implements ITerminalService { this._processSupportContextKey = TerminalContextKeys.processSupported.bindTo(this._contextKeyService); this._processSupportContextKey.set(!isWeb || this._remoteAgentService.getConnection() !== null); this._terminalHasBeenCreated = TerminalContextKeys.terminalHasBeenCreated.bindTo(this._contextKeyService); + this._terminalCountContextKey = TerminalContextKeys.count.bindTo(this._contextKeyService); lifecycleService.onBeforeShutdown(async e => e.veto(this._onBeforeShutdown(e.reason), 'veto.terminal')); lifecycleService.onWillShutdown(e => this._onWillShutdown(e)); @@ -446,6 +449,7 @@ export class TerminalService implements ITerminalService { const terminalIsOpenContext = TerminalContextKeys.isOpen.bindTo(this._contextKeyService); const updateTerminalContextKeys = () => { terminalIsOpenContext.set(this.instances.length > 0); + this._terminalCountContextKey.set(this.instances.length); }; this.onDidChangeInstances(() => updateTerminalContextKeys()); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalView.ts b/src/vs/workbench/contrib/terminal/browser/terminalView.ts index 75d335bae1b..048a1fe59c8 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalView.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalView.ts @@ -86,7 +86,8 @@ export class TerminalViewPane extends ViewPane { } this._onDidChangeViewWelcomeState.fire(); }); - this._terminalService.onDidCreateInstance(() => { + + this._terminalService.onDidChangeInstances(() => { if (!this._isWelcomeShowing) { return; } @@ -141,6 +142,8 @@ export class TerminalViewPane extends ViewPane { this._terminalsInitialized = true; this._terminalService.initializeTerminals(); } + } else { + this._onDidChangeViewWelcomeState.fire(); } if (hadTerminals) {