@@ -513,6 +513,12 @@ export class YamlCompletion {
513513 }
514514 }
515515
516+ const ignoreScalars =
517+ textBuffer . getLineContent ( overwriteRange . start . line ) . trim ( ) . length === 0 &&
518+ originalNode &&
519+ isScalar ( originalNode ) &&
520+ originalNode . value === null ;
521+
516522 // completion for object keys
517523 if ( node && isMap ( node ) ) {
518524 // don't suggest properties that are already present
@@ -534,7 +540,8 @@ export class YamlCompletion {
534540 collector ,
535541 textBuffer ,
536542 overwriteRange ,
537- doComplete
543+ doComplete ,
544+ ignoreScalars
538545 ) ;
539546
540547 if ( ! schema && currentWord . length > 0 && text . charAt ( offset - currentWord . length - 1 ) !== '"' ) {
@@ -549,7 +556,7 @@ export class YamlCompletion {
549556
550557 // proposals for values
551558 const types : { [ type : string ] : boolean } = { } ;
552- this . getValueCompletions ( schema , currentDoc , node , offset , document , collector , types , doComplete ) ;
559+ this . getValueCompletions ( schema , currentDoc , node , offset , document , collector , types , doComplete , ignoreScalars ) ;
553560 } catch ( err ) {
554561 this . telemetry ?. sendError ( 'yaml.completion.error' , err ) ;
555562 }
@@ -689,7 +696,8 @@ export class YamlCompletion {
689696 collector : CompletionsCollector ,
690697 textBuffer : TextBuffer ,
691698 overwriteRange : Range ,
692- doComplete : boolean
699+ doComplete : boolean ,
700+ ignoreScalars : boolean
693701 ) : void {
694702 const matchingSchemas = doc . getMatchingSchemas ( schema . schema , - 1 , null , doComplete ) ;
695703 const existingKey = textBuffer . getText ( overwriteRange ) ;
@@ -708,7 +716,6 @@ export class YamlCompletion {
708716 }
709717 } ) ;
710718 }
711- const ignoreScalars = lineContent . trim ( ) === '' && originalNode && isScalar ( originalNode ) && originalNode . value === null ;
712719
713720 for ( const schema of matchingSchemas ) {
714721 if (
@@ -886,7 +893,8 @@ export class YamlCompletion {
886893 document : TextDocument ,
887894 collector : CompletionsCollector ,
888895 types : { [ type : string ] : boolean } ,
889- doComplete : boolean
896+ doComplete : boolean ,
897+ ignoreScalars : boolean
890898 ) : void {
891899 let parentKey : string = null ;
892900
@@ -941,11 +949,11 @@ export class YamlCompletion {
941949 if ( s . schema . properties ) {
942950 const propertySchema = s . schema . properties [ parentKey ] ;
943951 if ( propertySchema ) {
944- this . addSchemaValueCompletions ( propertySchema , separatorAfter , collector , types , false ) ;
952+ this . addSchemaValueCompletions ( propertySchema , separatorAfter , collector , types , ignoreScalars ) ;
945953 }
946954 }
947955 if ( s . schema . additionalProperties ) {
948- this . addSchemaValueCompletions ( s . schema . additionalProperties , separatorAfter , collector , types , false ) ;
956+ this . addSchemaValueCompletions ( s . schema . additionalProperties , separatorAfter , collector , types , ignoreScalars ) ;
949957 }
950958 }
951959 }
0 commit comments