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 @@ -840,14 +840,16 @@ export class YamlCompletion {
840
840
841
841
if ( schema . schema . propertyNames && schema . schema . additionalProperties && schema . schema . type === 'object' ) {
842
842
const propertyNameSchema = asSchema ( schema . schema . propertyNames ) ;
843
- const label = propertyNameSchema . title || 'property' ;
844
- collector . add ( {
845
- kind : CompletionItemKind . Property ,
846
- label,
847
- insertText : '$' + `{1:${ label } }: ` ,
848
- insertTextFormat : InsertTextFormat . Snippet ,
849
- documentation : this . fromMarkup ( propertyNameSchema . markdownDescription ) || propertyNameSchema . description || '' ,
850
- } ) ;
843
+ if ( ! propertyNameSchema . deprecationMessage && ! propertyNameSchema . doNotSuggest ) {
844
+ const label = propertyNameSchema . title || 'property' ;
845
+ collector . add ( {
846
+ kind : CompletionItemKind . Property ,
847
+ label,
848
+ insertText : '$' + `{1:${ label } }: ` ,
849
+ insertTextFormat : InsertTextFormat . Snippet ,
850
+ documentation : this . fromMarkup ( propertyNameSchema . markdownDescription ) || propertyNameSchema . description || '' ,
851
+ } ) ;
852
+ }
851
853
}
852
854
}
853
855
Original file line number Diff line number Diff line change @@ -1480,6 +1480,22 @@ test1:
1480
1480
expect ( completion . items [ 0 ] . insertText ) . to . be . equal ( '${1:property}: ' ) ;
1481
1481
expect ( completion . items [ 0 ] . documentation ) . to . be . equal ( 'Property Description' ) ;
1482
1482
} ) ;
1483
+ it ( 'should not suggest propertyNames with doNotSuggest' , async ( ) => {
1484
+ const schema : JSONSchema = {
1485
+ type : 'object' ,
1486
+ additionalProperties : true ,
1487
+ propertyNames : {
1488
+ title : 'property' ,
1489
+ doNotSuggest : true ,
1490
+ } ,
1491
+ } ;
1492
+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
1493
+ const content = '' ;
1494
+ const completion = await parseSetup ( content , 0 , content . length ) ;
1495
+
1496
+ expect ( completion . items . length ) . equal ( 0 ) ;
1497
+ } ) ;
1498
+
1483
1499
it ( 'should suggest enum based on type' , async ( ) => {
1484
1500
const schema : JSONSchema = {
1485
1501
type : 'object' ,
You can’t perform that action at this time.
0 commit comments