| |
| |
| |
| |
| |
|
|
| import { |
| isLoadableSettingScope, |
| SettingScope, |
| type LoadableSettingScope, |
| type Settings, |
| } from '../config/settings.js'; |
| import { isInSettingsScope } from './settingsUtils.js'; |
|
|
| |
| |
| |
| export const SCOPE_LABELS = { |
| [SettingScope.User]: 'User Settings', |
| [SettingScope.Workspace]: 'Workspace Settings', |
| [SettingScope.System]: 'System Settings', |
| } as const; |
|
|
| |
| |
| |
| export function getScopeItems(): Array<{ |
| label: string; |
| value: LoadableSettingScope; |
| }> { |
| return [ |
| { label: SCOPE_LABELS[SettingScope.User], value: SettingScope.User }, |
| { |
| label: SCOPE_LABELS[SettingScope.Workspace], |
| value: SettingScope.Workspace, |
| }, |
| { label: SCOPE_LABELS[SettingScope.System], value: SettingScope.System }, |
| ]; |
| } |
|
|
| |
| |
| |
| export function getScopeMessageForSetting( |
| settingKey: string, |
| selectedScope: LoadableSettingScope, |
| settings: { |
| forScope: (scope: LoadableSettingScope) => { settings: Settings }; |
| }, |
| ): string { |
| const otherScopes = Object.values(SettingScope) |
| .filter(isLoadableSettingScope) |
| .filter((scope) => scope !== selectedScope); |
|
|
| const modifiedInOtherScopes = otherScopes.filter((scope) => { |
| const scopeSettings = settings.forScope(scope).settings; |
| return isInSettingsScope(settingKey, scopeSettings); |
| }); |
|
|
| if (modifiedInOtherScopes.length === 0) { |
| return ''; |
| } |
|
|
| const modifiedScopesStr = modifiedInOtherScopes.join(', '); |
| const currentScopeSettings = settings.forScope(selectedScope).settings; |
| const existsInCurrentScope = isInSettingsScope( |
| settingKey, |
| currentScopeSettings, |
| ); |
|
|
| return existsInCurrentScope |
| ? `(Also modified in ${modifiedScopesStr})` |
| : `(Modified in ${modifiedScopesStr})`; |
| } |
|
|