@@ -105,9 +105,17 @@ function getObjectValueType(schema: IJSONSchema): ObjectValue['type'] {
105
105
}
106
106
107
107
function getObjectDisplayValue ( element : SettingsTreeSettingElement ) : IObjectDataItem [ ] {
108
+ const elementDefaultValue : Record < string , unknown > = typeof element . defaultValue === 'object'
109
+ ? element . defaultValue ?? { }
110
+ : { } ;
111
+
112
+ const elementScopeValue : Record < string , unknown > = typeof element . scopeValue === 'object'
113
+ ? element . scopeValue ?? { }
114
+ : { } ;
115
+
108
116
const data = element . isConfigured ?
109
- { ...element . defaultValue , ...element . scopeValue } :
110
- element . defaultValue ;
117
+ { ...elementDefaultValue , ...elementScopeValue } :
118
+ elementDefaultValue ;
111
119
112
120
const { objectProperties, objectPatternProperties, objectAdditionalProperties } = element . setting ;
113
121
const patternsAndSchemas = Object
@@ -129,7 +137,7 @@ function getObjectDisplayValue(element: SettingsTreeSettingElement): IObjectData
129
137
130
138
return Object . keys ( data ) . map ( key => {
131
139
if ( isDefined ( objectProperties ) && key in objectProperties ) {
132
- const defaultValue = element . defaultValue [ key ] ;
140
+ const defaultValue = elementDefaultValue [ key ] ;
133
141
const valueEnumOptions = getEnumOptionsFromSchema ( objectProperties [ key ] ) ;
134
142
135
143
return {
@@ -144,7 +152,7 @@ function getObjectDisplayValue(element: SettingsTreeSettingElement): IObjectData
144
152
options : valueEnumOptions ,
145
153
} ,
146
154
removable : isUndefinedOrNull ( defaultValue ) ,
147
- } ;
155
+ } as IObjectDataItem ;
148
156
}
149
157
150
158
const schema = patternsAndSchemas . find ( ( { pattern } ) => pattern . test ( key ) ) ?. schema ;
@@ -159,7 +167,7 @@ function getObjectDisplayValue(element: SettingsTreeSettingElement): IObjectData
159
167
options : valueEnumOptions ,
160
168
} ,
161
169
removable : true ,
162
- } ;
170
+ } as IObjectDataItem ;
163
171
}
164
172
165
173
return {
@@ -170,7 +178,7 @@ function getObjectDisplayValue(element: SettingsTreeSettingElement): IObjectData
170
178
options : additionalValueEnums ,
171
179
} ,
172
180
removable : true ,
173
- } ;
181
+ } as IObjectDataItem ;
174
182
} ) ;
175
183
}
176
184
@@ -1055,8 +1063,14 @@ export class SettingObjectRenderer extends AbstractSettingRenderer implements IT
1055
1063
1056
1064
private onDidChangeObject ( template : ISettingObjectItemTemplate , e : ISettingListChangeEvent < IObjectDataItem > ) : void {
1057
1065
if ( template . context ) {
1058
- const defaultValue : Record < string , unknown > = template . context . defaultValue ;
1059
- const scopeValue : Record < string , unknown > = template . context . scopeValue ;
1066
+ const defaultValue : Record < string , unknown > = typeof template . context . defaultValue === 'object'
1067
+ ? template . context . defaultValue ?? { }
1068
+ : { } ;
1069
+
1070
+ const scopeValue : Record < string , unknown > = typeof template . context . scopeValue === 'object'
1071
+ ? template . context . scopeValue ?? { }
1072
+ : { } ;
1073
+
1060
1074
const newValue : Record < string , unknown > = { } ;
1061
1075
let newItems : IObjectDataItem [ ] = [ ] ;
1062
1076
0 commit comments