use terminal settings prefixes

This commit is contained in:
meganrogge 2021-08-04 11:37:13 -07:00
parent 8d87bdf345
commit dc00abecfa
No known key found for this signature in database
GPG key ID: 3155C8B2F0428C81
2 changed files with 12 additions and 11 deletions

View file

@ -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);
}

View file

@ -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<IProfileQuickPickItem> = {
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<void> {
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;
}