From dc00abecfaaefbe683e27f27c8e6e4f529fcfab8 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 4 Aug 2021 11:37:13 -0700 Subject: [PATCH] use terminal settings prefixes --- .../browser/terminalProfileResolverService.ts | 4 ++-- .../terminal/browser/terminalService.ts | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts b/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts index a06b112e218..a39d2c2b589 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts @@ -13,7 +13,7 @@ import { IRemoteTerminalService, ITerminalService } from 'vs/workbench/contrib/t import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IProcessEnvironment, OperatingSystem, OS } from 'vs/base/common/platform'; -import { IShellLaunchConfig, ITerminalProfile, TerminalIcon, TerminalSettingId } from 'vs/platform/terminal/common/terminal'; +import { IShellLaunchConfig, ITerminalProfile, TerminalIcon, TerminalSettingId, TerminalSettingPrefix } from 'vs/platform/terminal/common/terminal'; import { IShellLaunchConfigResolveOptions, ITerminalProfileResolverService } from 'vs/workbench/contrib/terminal/common/terminal'; import * as path from 'vs/base/common/path'; import { Codicon, iconRegistry } from 'vs/base/common/codicons'; @@ -209,7 +209,7 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro } private _getUnresolvedRealDefaultProfile(os: OperatingSystem): ITerminalProfile | undefined { - const defaultProfileName = this._configurationService.getValue(`terminal.integrated.defaultProfile.${this._getOsKey(os)}`); + const defaultProfileName = this._configurationService.getValue(`${TerminalSettingPrefix.DefaultProfile}.${this._getOsKey(os)}`); if (defaultProfileName && typeof defaultProfileName === 'string') { return this._terminalService.availableProfiles.find(e => e.profileName === defaultProfileName); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index 4b40f9f8e4b..e13a076da08 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -842,6 +842,8 @@ export class TerminalService implements ITerminalService { let keyMods: IKeyMods | undefined; const profiles = await this._detectProfiles(true); const platformKey = await this._getPlatformKey(); + const profilesKey = `${TerminalSettingPrefix.Profiles}${platformKey}`; + const defaultProfileKey = `${TerminalSettingPrefix.DefaultProfile}${platformKey}`; const options: IPickOptions = { placeHolder: type === 'createInstance' ? nls.localize('terminal.integrated.selectProfileToCreate', "Select the terminal profile to create") : nls.localize('terminal.integrated.chooseDefaultProfile', "Select your default terminal profile"), @@ -852,8 +854,7 @@ export class TerminalService implements ITerminalService { if ('id' in context.item.profile) { return; } - const configKey = `terminal.integrated.profiles.${platformKey}`; - const configProfiles = this._configurationService.getValue<{ [key: string]: ITerminalProfileObject }>(configKey); + const configProfiles = this._configurationService.getValue<{ [key: string]: ITerminalProfileObject }>(profilesKey); const existingProfiles = configProfiles ? Object.keys(configProfiles) : []; const name = await this._quickInputService.input({ prompt: nls.localize('enterTerminalProfileName', "Enter terminal profile name"), @@ -873,7 +874,7 @@ export class TerminalService implements ITerminalService { path: context.item.profile.path, args: context.item.profile.args }; - await this._configurationService.updateValue(configKey, newConfigValue, ConfigurationTarget.USER); + await this._configurationService.updateValue(profilesKey, newConfigValue, ConfigurationTarget.USER); }, onKeyMods: mods => keyMods = mods }; @@ -940,7 +941,7 @@ export class TerminalService implements ITerminalService { return; // Should never happen } else if ('id' in value.profile) { // extension contributed profile - await this._configurationService.updateValue(`terminal.integrated.defaultProfile.${platformKey}`, value.profile.title, ConfigurationTarget.USER); + await this._configurationService.updateValue(defaultProfileKey, value.profile.title, ConfigurationTarget.USER); this._registerContributedProfile(value.profile.extensionIdentifier, value.profile.id, value.profile.title, { color: value.profile.color, @@ -952,7 +953,7 @@ export class TerminalService implements ITerminalService { // Add the profile to settings if necessary if (value.profile.isAutoDetected) { - const profilesConfig = await this._configurationService.getValue(`terminal.integrated.profiles.${platformKey}`); + const profilesConfig = await this._configurationService.getValue(profilesKey); if (typeof profilesConfig === 'object') { const newProfile: ITerminalProfileObject = { path: value.profile.path @@ -962,10 +963,10 @@ export class TerminalService implements ITerminalService { } (profilesConfig as { [key: string]: ITerminalProfileObject })[value.profile.profileName] = newProfile; } - await this._configurationService.updateValue(`terminal.integrated.profiles.${platformKey}`, profilesConfig, ConfigurationTarget.USER); + await this._configurationService.updateValue(profilesKey, profilesConfig, ConfigurationTarget.USER); } // Set the default profile - await this._configurationService.updateValue(`terminal.integrated.defaultProfile.${platformKey}`, value.profile.profileName, ConfigurationTarget.USER); + await this._configurationService.updateValue(defaultProfileKey, value.profile.profileName, ConfigurationTarget.USER); return undefined; } @@ -1010,7 +1011,7 @@ export class TerminalService implements ITerminalService { private async _registerContributedProfile(extensionIdentifier: string, id: string, title: string, options: ICreateContributedTerminalProfileOptions): Promise { const platformKey = await this._getPlatformKey(); - const profilesConfig = await this._configurationService.getValue(`terminal.integrated.profiles.${platformKey}`); + const profilesConfig = await this._configurationService.getValue(`${TerminalSettingPrefix.Profiles}${platformKey}`); if (typeof profilesConfig === 'object') { const newProfile: IExtensionTerminalProfile = { extensionIdentifier: extensionIdentifier, @@ -1022,7 +1023,7 @@ export class TerminalService implements ITerminalService { (profilesConfig as { [key: string]: ITerminalProfileObject })[title] = newProfile; } - await this._configurationService.updateValue(`terminal.integrated.profiles.${platformKey}`, profilesConfig, ConfigurationTarget.USER); + await this._configurationService.updateValue(`${TerminalSettingPrefix.Profiles}${platformKey}`, profilesConfig, ConfigurationTarget.USER); return; }