File tree 2 files changed +26
-8
lines changed
src/languageservice/services
2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -1025,14 +1025,16 @@ export class YamlCompletion {
1025
1025
1026
1026
if ( schema . schema . propertyNames && schema . schema . additionalProperties && schema . schema . type === 'object' ) {
1027
1027
const propertyNameSchema = asSchema ( schema . schema . propertyNames ) ;
1028
- const label = propertyNameSchema . title || 'property' ;
1029
- collector . add ( {
1030
- kind : CompletionItemKind . Property ,
1031
- label,
1032
- insertText : '$' + `{1:${ label } }: ` ,
1033
- insertTextFormat : InsertTextFormat . Snippet ,
1034
- documentation : this . fromMarkup ( propertyNameSchema . markdownDescription ) || propertyNameSchema . description || '' ,
1035
- } ) ;
1028
+ if ( ! propertyNameSchema . deprecationMessage && ! propertyNameSchema . doNotSuggest ) {
1029
+ const label = propertyNameSchema . title || 'property' ;
1030
+ collector . add ( {
1031
+ kind : CompletionItemKind . Property ,
1032
+ label,
1033
+ insertText : '$' + `{1:${ label } }: ` ,
1034
+ insertTextFormat : InsertTextFormat . Snippet ,
1035
+ documentation : this . fromMarkup ( propertyNameSchema . markdownDescription ) || propertyNameSchema . description || '' ,
1036
+ } ) ;
1037
+ }
1036
1038
}
1037
1039
}
1038
1040
Original file line number Diff line number Diff line change @@ -2230,6 +2230,22 @@ test1:
2230
2230
expect ( completion . items [ 0 ] . documentation ) . to . be . equal ( 'Property Description' ) ;
2231
2231
} ) ;
2232
2232
2233
+ it ( 'should not suggest propertyNames with doNotSuggest' , async ( ) => {
2234
+ const schema : JSONSchema = {
2235
+ type : 'object' ,
2236
+ additionalProperties : true ,
2237
+ propertyNames : {
2238
+ title : 'property' ,
2239
+ doNotSuggest : true ,
2240
+ } ,
2241
+ } ;
2242
+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
2243
+ const content = '' ;
2244
+ const completion = await parseSetup ( content , 0 , content . length ) ;
2245
+
2246
+ expect ( completion . items . length ) . equal ( 0 ) ;
2247
+ } ) ;
2248
+
2233
2249
describe ( 'Deprecated schema' , ( ) => {
2234
2250
it ( 'should not autocomplete deprecated schema - property completion' , async ( ) => {
2235
2251
const schema : JSONSchema = {
You can’t perform that action at this time.
0 commit comments