Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable opt-out of contributed profiles #135791

Merged
merged 2 commits into from Oct 25, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Expand Up @@ -8,7 +8,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { FindReplaceState } from 'vs/editor/contrib/find/findState';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalLaunchError, ITerminalProfile, ITerminalTabLayoutInfoById, TerminalIcon, TitleEventSource, TerminalShellType, IExtensionTerminalProfile, ITerminalProfileType, TerminalLocation, ICreateContributedTerminalProfileOptions, ProcessPropertyType, ProcessCapability } from 'vs/platform/terminal/common/terminal';
import { IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalLaunchError, ITerminalProfile, ITerminalTabLayoutInfoById, TerminalIcon, TitleEventSource, TerminalShellType, IExtensionTerminalProfile, TerminalLocation, ICreateContributedTerminalProfileOptions, ProcessPropertyType, ProcessCapability } from 'vs/platform/terminal/common/terminal';
import { ICommandTracker, INavigationMode, IOffProcessTerminalService, IRemoteTerminalAttachTarget, IStartExtensionTerminalRequest, ITerminalConfigHelper, ITerminalProcessExtHostProxy } from 'vs/workbench/contrib/terminal/common/terminal';
import type { Terminal as XTermTerminal } from 'xterm';
import type { SearchAddon as XTermSearchAddon } from 'xterm-addon-search';
Expand Down Expand Up @@ -109,7 +109,7 @@ export interface ITerminalService extends ITerminalInstanceHost {
isProcessSupportRegistered: boolean;
readonly connectionState: TerminalConnectionState;
readonly availableProfiles: ITerminalProfile[];
readonly allProfiles: ITerminalProfileType[] | undefined;
readonly contributedProfiles: IExtensionTerminalProfile[];
readonly profilesReady: Promise<void>;
readonly defaultLocation: TerminalLocation;

Expand Down
4 changes: 1 addition & 3 deletions src/vs/workbench/contrib/terminal/browser/terminalEditor.ts
Expand Up @@ -24,7 +24,6 @@ import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/termi
import { TerminalFindWidget } from 'vs/workbench/contrib/terminal/browser/terminalFindWidget';
import { getTerminalActionBarArgs } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
import { ITerminalProfileResolverService, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalContributionService } from 'vs/workbench/contrib/terminal/common/terminalExtensionPoints';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { isLinux, isMacintosh } from 'vs/base/common/platform';
import { BrowserFeatures } from 'vs/base/browser/canIUse';
Expand Down Expand Up @@ -63,7 +62,6 @@ export class TerminalEditor extends EditorPane {
@IStorageService storageService: IStorageService,
@ITerminalEditorService private readonly _terminalEditorService: ITerminalEditorService,
@ITerminalProfileResolverService private readonly _terminalProfileResolverService: ITerminalProfileResolverService,
@ITerminalContributionService private readonly _terminalContributionService: ITerminalContributionService,
@ITerminalService private readonly _terminalService: ITerminalService,
@IInstantiationService instantiationService: IInstantiationService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
Expand Down Expand Up @@ -203,7 +201,7 @@ export class TerminalEditor extends EditorPane {
switch (action.id) {
case TerminalCommandId.CreateWithProfileButton: {
const location = { viewColumn: ACTIVE_GROUP };
const actions = getTerminalActionBarArgs(location, this._terminalService.availableProfiles, this._getDefaultProfileName(), this._terminalContributionService.terminalProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
const actions = getTerminalActionBarArgs(location, this._terminalService.availableProfiles, this._getDefaultProfileName(), this._terminalService.contributedProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
const button = this._instantiationService.createInstance(DropdownWithPrimaryActionViewItem, actions.primaryAction, actions.dropdownAction, actions.dropdownMenuActions, actions.className, this._contextMenuService, {});
return button;
}
Expand Down
34 changes: 19 additions & 15 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Expand Up @@ -23,7 +23,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IKeyMods, IPickOptions, IQuickInputButton, IQuickInputService, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ICreateContributedTerminalProfileOptions, IExtensionTerminalProfile, IShellLaunchConfig, ITerminalLaunchError, ITerminalProfile, ITerminalProfileObject, ITerminalProfileType, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalLocation, TerminalLocationString, TerminalSettingId, TerminalSettingPrefix } from 'vs/platform/terminal/common/terminal';
import { ICreateContributedTerminalProfileOptions, IExtensionTerminalProfile, IShellLaunchConfig, ITerminalLaunchError, ITerminalProfile, ITerminalProfileObject, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalLocation, TerminalLocationString, TerminalSettingId, TerminalSettingPrefix } from 'vs/platform/terminal/common/terminal';
import { registerTerminalDefaultProfileConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration';
import { iconForeground } from 'vs/platform/theme/common/colorRegistry';
import { IconDefinition } from 'vs/platform/theme/common/iconRegistry';
Expand Down Expand Up @@ -72,7 +72,7 @@ export class TerminalService implements ITerminalService {
private _defaultProfileName?: string;
private _profilesReadyBarrier: AutoOpenBarrier;
private _availableProfiles: ITerminalProfile[] | undefined;
private _contributedProfiles: IExtensionTerminalProfile[] | undefined;
private _contributedProfiles: IExtensionTerminalProfile[] = [];
private _configHelper: TerminalConfigHelper;
private _remoteTerminalsInitPromise: Promise<void> | undefined;
private _localTerminalsInitPromise: Promise<void> | undefined;
Expand All @@ -89,14 +89,8 @@ export class TerminalService implements ITerminalService {
this._refreshAvailableProfiles();
return this._availableProfiles || [];
}
get allProfiles(): ITerminalProfileType[] | undefined {
if (this._availableProfiles) {
const profiles: ITerminalProfileType[] = [];
profiles.concat(this._availableProfiles);
profiles.concat(this._terminalContributionService.terminalProfiles);
return profiles;
}
return undefined;
get contributedProfiles(): IExtensionTerminalProfile[] {
return this._contributedProfiles || [];
}
get configHelper(): ITerminalConfigHelper { return this._configHelper; }
get instances(): ITerminalInstance[] {
Expand Down Expand Up @@ -511,9 +505,19 @@ export class TerminalService implements ITerminalService {
}

private async _refreshAvailableProfilesNow(): Promise<void> {
const platformKey = await this._getPlatformKey();
const profiles = await this._detectProfiles();
const profilesChanged = !equals(profiles, this._availableProfiles);
const contributedProfilesChanged = !equals(this._terminalContributionService.terminalProfiles, this._contributedProfiles);
const excludedContributedProfiles: string[] = [];
const configProfiles: { [key: string]: any } = this._configurationService.getValue(TerminalSettingPrefix.Profiles + platformKey);
for (const [profileName, value] of Object.entries(configProfiles)) {
if (value === null) {
excludedContributedProfiles.push(profileName);
}
}
const filteredContributedProfiles = Array.from(this._terminalContributionService.terminalProfiles.filter(p => !excludedContributedProfiles.includes(p.title)));
const contributedProfilesChanged = !equals(filteredContributedProfiles, this._contributedProfiles);

if (profiles.length === 0 && this._ifNoProfilesTryAgain) {
// available profiles get updated when a terminal is created
// or relevant config changes.
Expand All @@ -525,7 +529,7 @@ export class TerminalService implements ITerminalService {
}
if (profilesChanged || contributedProfilesChanged) {
this._availableProfiles = profiles;
this._contributedProfiles = Array.from(this._terminalContributionService.terminalProfiles);
this._contributedProfiles = filteredContributedProfiles;
this._onDidChangeAvailableProfiles.fire(this._availableProfiles);
this._profilesReadyBarrier.open();
this._updateWebContextKey();
Expand All @@ -534,12 +538,12 @@ export class TerminalService implements ITerminalService {
}

private _updateWebContextKey(): void {
this._webExtensionContributedProfileContextKey.set(isWeb && this._terminalContributionService.terminalProfiles.length > 0);
this._webExtensionContributedProfileContextKey.set(isWeb && this._contributedProfiles.length > 0);
}

private async _refreshPlatformConfig(profiles: ITerminalProfile[]) {
const env = await this._remoteAgentService.getEnvironment();
registerTerminalDefaultProfileConfiguration({ os: env?.os || OS, profiles }, this._terminalContributionService.terminalProfiles);
registerTerminalDefaultProfileConfiguration({ os: env?.os || OS, profiles }, this._contributedProfiles);
refreshTerminalActions(profiles);
}

Expand Down Expand Up @@ -987,7 +991,7 @@ export class TerminalService implements ITerminalService {

quickPickItems.push({ type: 'separator', label: nls.localize('ICreateContributedTerminalProfileOptions', "contributed") });
const contributedProfiles: IProfileQuickPickItem[] = [];
for (const contributed of this._terminalContributionService.terminalProfiles) {
for (const contributed of this.contributedProfiles) {
if (typeof contributed.icon === 'string' && contributed.icon.startsWith('$(')) {
contributed.icon = contributed.icon.substring(2, contributed.icon.length - 1);
}
Expand Down
8 changes: 3 additions & 5 deletions src/vs/workbench/contrib/terminal/browser/terminalView.ts
Expand Up @@ -25,7 +25,6 @@ import { IMenu, IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions
import { ITerminalProfileResolverService, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
import { TerminalSettingId, ITerminalProfile, TerminalLocation } from 'vs/platform/terminal/common/terminal';
import { ActionViewItem, SelectActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { ITerminalContributionService } from 'vs/workbench/contrib/terminal/common/terminalExtensionPoints';
import { attachSelectBoxStyler, attachStylerCallback } from 'vs/platform/theme/common/styler';
import { selectBorder } from 'vs/platform/theme/common/colorRegistry';
import { ISelectOptionItem } from 'vs/base/browser/ui/selectBox/selectBox';
Expand Down Expand Up @@ -75,8 +74,7 @@ export class TerminalViewPane extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IMenuService private readonly _menuService: IMenuService,
@ICommandService private readonly _commandService: ICommandService,
@ITerminalContributionService private readonly _terminalContributionService: ITerminalContributionService,
@ITerminalProfileResolverService private readonly _terminalProfileResolverService: ITerminalProfileResolverService,
@ITerminalProfileResolverService private readonly _terminalProfileResolverService: ITerminalProfileResolverService
) {
super(options, keybindingService, _contextMenuService, configurationService, _contextKeyService, viewDescriptorService, _instantiationService, openerService, themeService, telemetryService);
this._terminalService.onDidRegisterProcessSupport(() => {
Expand Down Expand Up @@ -204,7 +202,7 @@ export class TerminalViewPane extends ViewPane {
this._tabButtons.dispose();
}

const actions = getTerminalActionBarArgs(TerminalLocation.Panel, this._terminalService.availableProfiles, this._getDefaultProfileName(), this._terminalContributionService.terminalProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
const actions = getTerminalActionBarArgs(TerminalLocation.Panel, this._terminalService.availableProfiles, this._getDefaultProfileName(), this._terminalService.contributedProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
this._tabButtons = new DropdownWithPrimaryActionViewItem(actions.primaryAction, actions.dropdownAction, actions.dropdownMenuActions, actions.className, this._contextMenuService, {}, this._keybindingService, this._notificationService, this._contextKeyService);
this._updateTabActionBar(this._terminalService.availableProfiles);
return this._tabButtons;
Expand All @@ -228,7 +226,7 @@ export class TerminalViewPane extends ViewPane {
}

private _updateTabActionBar(profiles: ITerminalProfile[]): void {
const actions = getTerminalActionBarArgs(TerminalLocation.Panel, profiles, this._getDefaultProfileName(), this._terminalContributionService.terminalProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
const actions = getTerminalActionBarArgs(TerminalLocation.Panel, profiles, this._getDefaultProfileName(), this._terminalService.contributedProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
this._tabButtons?.update(actions.dropdownAction, actions.dropdownMenuActions);
}

Expand Down