fix(cli): hide read-only settings scopes (#26249)

This commit is contained in:
Christian Van
2026-05-06 15:03:48 -04:00
committed by GitHub
parent 7fb5146c6b
commit e4242edf61
6 changed files with 251 additions and 29 deletions
+38
View File
@@ -3005,6 +3005,44 @@ describe('Settings Loading and Merging', () => {
expect(snap1).toBe(snap2);
});
it('getSnapshot() should preserve readOnly metadata for each scope', () => {
const readonlySettings = new LoadedSettings(
{
path: getSystemSettingsPath(),
settings: {},
originalSettings: {},
readOnly: true,
},
{
path: getSystemDefaultsPath(),
settings: {},
originalSettings: {},
readOnly: true,
},
{
path: USER_SETTINGS_PATH,
settings: {},
originalSettings: {},
readOnly: false,
},
{
path: MOCK_WORKSPACE_SETTINGS_PATH,
settings: {},
originalSettings: {},
readOnly: true,
},
true,
[],
);
const snapshot = readonlySettings.getSnapshot();
expect(snapshot.system.readOnly).toBe(true);
expect(snapshot.systemDefaults.readOnly).toBe(true);
expect(snapshot.user.readOnly).toBe(false);
expect(snapshot.workspace.readOnly).toBe(true);
});
it('setValue() should create a new snapshot reference and emit event', () => {
const oldSnapshot = loadedSettings.getSnapshot();
const oldUserRef = oldSnapshot.user.settings;
+1 -2
View File
@@ -398,8 +398,7 @@ export class LoadedSettings {
private computeSnapshot(): LoadedSettingsSnapshot {
const cloneSettingsFile = (file: SettingsFile): SettingsFile => ({
path: file.path,
rawJson: file.rawJson,
...file,
settings: structuredClone(file.settings),
originalSettings: structuredClone(file.originalSettings),
});