( key: string, settings: Settings, _mergedSettings: Settings, modifiedSettings: Set<string>, pendingSettings?: Settings, )
| 405 | * Get the display value for a setting, showing current scope value with default change indicator |
| 406 | */ |
| 407 | export function getDisplayValue( |
| 408 | key: string, |
| 409 | settings: Settings, |
| 410 | _mergedSettings: Settings, |
| 411 | modifiedSettings: Set<string>, |
| 412 | pendingSettings?: Settings, |
| 413 | ): string { |
| 414 | // Prioritize pending changes if user has modified this setting |
| 415 | let value: boolean; |
| 416 | if (pendingSettings && settingExistsInScope(key, pendingSettings)) { |
| 417 | // Show the value from the pending (unsaved) edits when it exists |
| 418 | value = getSettingValue(key, pendingSettings, {}); |
| 419 | } else if (settingExistsInScope(key, settings)) { |
| 420 | // Show the value defined at the current scope if present |
| 421 | value = getSettingValue(key, settings, {}); |
| 422 | } else { |
| 423 | // Fall back to the schema default when the key is unset in this scope |
| 424 | const defaultValue = getDefaultValue(key); |
| 425 | value = typeof defaultValue === 'boolean' ? defaultValue : false; |
| 426 | } |
| 427 | |
| 428 | const valueString = String(value); |
| 429 | |
| 430 | // Check if value is different from default OR if it's in modified settings OR if there are pending changes |
| 431 | const defaultValue = getDefaultValue(key); |
| 432 | const isChangedFromDefault = |
| 433 | typeof defaultValue === 'boolean' ? value !== defaultValue : value === true; |
| 434 | const isInModifiedSettings = modifiedSettings.has(key); |
| 435 | const hasPendingChanges = |
| 436 | pendingSettings && settingExistsInScope(key, pendingSettings); |
| 437 | |
| 438 | // Add * indicator when value differs from default, is in modified settings, or has pending changes |
| 439 | if (isChangedFromDefault || isInModifiedSettings || hasPendingChanges) { |
| 440 | return `${valueString}*`; // * indicates changed from default value |
| 441 | } |
| 442 | |
| 443 | return valueString; |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * Check if a setting doesn't exist in current scope (should be greyed out) |
no test coverage detected