Skip to content

Commit 2f1e5cb

Browse files
authored
don't show welcome view when web extension terminal is created (microsoft#136327)
1 parent fd21ba3 commit 2f1e5cb

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

src/vs/workbench/api/common/extHostTerminalService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,14 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
672672

673673
public async $createContributedProfileTerminal(id: string, options: ICreateContributedTerminalProfileOptions): Promise<void> {
674674
const token = new CancellationTokenSource().token;
675-
const profile = await this._profileProviders.get(id)?.provideTerminalProfile(token);
675+
let profile = await this._profileProviders.get(id)?.provideTerminalProfile(token);
676676
if (token.isCancellationRequested) {
677677
return;
678678
}
679+
if (profile && !('options' in profile)) {
680+
profile = { options: profile };
681+
}
682+
679683
if (!profile || !('options' in profile)) {
680684
throw new Error(`No terminal profile options provided for id "${id}"`);
681685
}

src/vs/workbench/contrib/terminal/browser/terminalActions.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ export function registerTerminalActions() {
14441444
title: terminalStrings.split,
14451445
f1: true,
14461446
category,
1447-
precondition: TerminalContextKeys.processSupported,
1447+
precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.webExtensionContributedProfile),
14481448
keybinding: {
14491449
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Digit5,
14501450
weight: KeybindingWeight.WorkbenchContrib,
@@ -1632,7 +1632,7 @@ export function registerTerminalActions() {
16321632
title: { value: localize('workbench.action.terminal.new', "Create New Terminal"), original: 'Create New Terminal' },
16331633
f1: true,
16341634
category,
1635-
precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported),
1635+
precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.webExtensionContributedProfile),
16361636
icon: Codicon.plus,
16371637
keybinding: {
16381638
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Backquote,
@@ -1703,6 +1703,8 @@ export function registerTerminalActions() {
17031703
} else {
17041704
await terminalGroupService.showPanel(true);
17051705
}
1706+
} else if (TerminalContextKeys.webExtensionContributedProfile) {
1707+
commandService.executeCommand(TerminalCommandId.NewWithProfile);
17061708
}
17071709
}
17081710
});
@@ -2089,7 +2091,7 @@ export function refreshTerminalActions(detectedProfiles: ITerminalProfile[]) {
20892091
title: { value: localize('workbench.action.terminal.newWithProfile', "Create New Terminal (With Profile)"), original: 'Create New Terminal (With Profile)' },
20902092
f1: true,
20912093
category,
2092-
precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported),
2094+
precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.webExtensionContributedProfile),
20932095
description: {
20942096
description: 'workbench.action.terminal.newWithProfile',
20952097
args: [{
@@ -2114,10 +2116,6 @@ export function refreshTerminalActions(detectedProfiles: ITerminalProfile[]) {
21142116
const terminalService = accessor.get(ITerminalService);
21152117
const terminalProfileService = accessor.get(ITerminalProfileService);
21162118

2117-
if (!terminalService.isProcessSupportRegistered) {
2118-
return;
2119-
}
2120-
21212119
const terminalGroupService = accessor.get(ITerminalGroupService);
21222120
const workspaceContextService = accessor.get(IWorkspaceContextService);
21232121
const commandService = accessor.get(ICommandService);

src/vs/workbench/contrib/terminal/browser/terminalGroupService.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
3232
}
3333

3434
private _terminalGroupCountContextKey: IContextKey<number>;
35-
private _terminalCountContextKey: IContextKey<number>;
3635

3736
private _container: HTMLElement | undefined;
3837

@@ -70,10 +69,8 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
7069
this.onDidDisposeGroup(group => this._removeGroup(group));
7170

7271
this._terminalGroupCountContextKey = TerminalContextKeys.groupCount.bindTo(this._contextKeyService);
73-
this._terminalCountContextKey = TerminalContextKeys.count.bindTo(this._contextKeyService);
7472

7573
this.onDidChangeGroups(() => this._terminalGroupCountContextKey.set(this.groups.length));
76-
this.onDidChangeInstances(() => this._terminalCountContextKey.set(this.instances.length));
7774

7875
this._findState = new FindReplaceState();
7976
}

src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class TerminalProfileService implements ITerminalProfileService {
7272
}
7373
});
7474
this._webExtensionContributedProfileContextKey = TerminalContextKeys.webExtensionContributedProfile.bindTo(this._contextKeyService);
75-
75+
this._updateWebContextKey();
7676
this._primaryOffProcessTerminalService = !!this._environmentService.remoteAuthority ? this._remoteTerminalService : (this._localTerminalService || this._remoteTerminalService);
7777
// Wait up to 5 seconds for profiles to be ready so it's assured that we know the actual
7878
// default terminal before launching the first terminal. This isn't expected to ever take

src/vs/workbench/contrib/terminal/browser/terminalService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export class TerminalService implements ITerminalService {
6161
private _processSupportContextKey: IContextKey<boolean>;
6262

6363
private _terminalHasBeenCreated: IContextKey<boolean>;
64+
private _terminalCountContextKey: IContextKey<number>;
65+
6466
private readonly _localTerminalService?: ILocalTerminalService;
6567
private readonly _primaryOffProcessTerminalService?: IOffProcessTerminalService;
6668
private _configHelper: TerminalConfigHelper;
@@ -225,6 +227,7 @@ export class TerminalService implements ITerminalService {
225227
this._processSupportContextKey = TerminalContextKeys.processSupported.bindTo(this._contextKeyService);
226228
this._processSupportContextKey.set(!isWeb || this._remoteAgentService.getConnection() !== null);
227229
this._terminalHasBeenCreated = TerminalContextKeys.terminalHasBeenCreated.bindTo(this._contextKeyService);
230+
this._terminalCountContextKey = TerminalContextKeys.count.bindTo(this._contextKeyService);
228231

229232
lifecycleService.onBeforeShutdown(async e => e.veto(this._onBeforeShutdown(e.reason), 'veto.terminal'));
230233
lifecycleService.onWillShutdown(e => this._onWillShutdown(e));
@@ -446,6 +449,7 @@ export class TerminalService implements ITerminalService {
446449
const terminalIsOpenContext = TerminalContextKeys.isOpen.bindTo(this._contextKeyService);
447450
const updateTerminalContextKeys = () => {
448451
terminalIsOpenContext.set(this.instances.length > 0);
452+
this._terminalCountContextKey.set(this.instances.length);
449453
};
450454
this.onDidChangeInstances(() => updateTerminalContextKeys());
451455
}

src/vs/workbench/contrib/terminal/browser/terminalView.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export class TerminalViewPane extends ViewPane {
8686
}
8787
this._onDidChangeViewWelcomeState.fire();
8888
});
89-
this._terminalService.onDidCreateInstance(() => {
89+
90+
this._terminalService.onDidChangeInstances(() => {
9091
if (!this._isWelcomeShowing) {
9192
return;
9293
}
@@ -141,6 +142,8 @@ export class TerminalViewPane extends ViewPane {
141142
this._terminalsInitialized = true;
142143
this._terminalService.initializeTerminals();
143144
}
145+
} else {
146+
this._onDidChangeViewWelcomeState.fire();
144147
}
145148

146149
if (hadTerminals) {

0 commit comments

Comments
 (0)