@@ -325,7 +325,7 @@ export class Parser {
325325 it . value = token
326326 } else {
327327 Object . assign ( it , { key : token , sep : [ ] } )
328- this . onKeyLine = ! includesToken ( it . start , 'explicit-key-ind' )
328+ this . onKeyLine = ! it . explicitKey
329329 return
330330 }
331331 break
@@ -532,7 +532,7 @@ export class Parser {
532532 const atNextItem =
533533 ! this . onKeyLine &&
534534 this . indent === map . indent &&
535- it . sep &&
535+ ( it . sep || it . explicitKey ) &&
536536 this . type !== 'seq-item-ind'
537537
538538 // For empty nodes, assign newline-separated not indented empty tokens to following node
@@ -572,24 +572,25 @@ export class Parser {
572572 return
573573
574574 case 'explicit-key-ind' :
575- if ( ! it . sep && ! includesToken ( it . start , 'explicit-key-ind' ) ) {
575+ if ( ! it . sep && ! it . explicitKey ) {
576576 it . start . push ( this . sourceToken )
577+ it . explicitKey = true
577578 } else if ( atNextItem || it . value ) {
578579 start . push ( this . sourceToken )
579- map . items . push ( { start } )
580+ map . items . push ( { start, explicitKey : true } )
580581 } else {
581582 this . stack . push ( {
582583 type : 'block-map' ,
583584 offset : this . offset ,
584585 indent : this . indent ,
585- items : [ { start : [ this . sourceToken ] } ]
586+ items : [ { start : [ this . sourceToken ] , explicitKey : true } ]
586587 } )
587588 }
588589 this . onKeyLine = true
589590 return
590591
591592 case 'map-value-ind' :
592- if ( includesToken ( it . start , 'explicit-key-ind' ) ) {
593+ if ( it . explicitKey ) {
593594 if ( ! it . sep ) {
594595 if ( includesToken ( it . start , 'newline' ) ) {
595596 Object . assign ( it , { key : null , sep : [ this . sourceToken ] } )
@@ -672,11 +673,7 @@ export class Parser {
672673 default : {
673674 const bv = this . startBlockValue ( map )
674675 if ( bv ) {
675- if (
676- atNextItem &&
677- bv . type !== 'block-seq' &&
678- includesToken ( it . start , 'explicit-key-ind' )
679- ) {
676+ if ( atNextItem && bv . type !== 'block-seq' && it . explicitKey ) {
680677 map . items . push ( { start } )
681678 }
682679 this . stack . push ( bv )
@@ -888,7 +885,7 @@ export class Parser {
888885 type : 'block-map' ,
889886 offset : this . offset ,
890887 indent : this . indent ,
891- items : [ { start } ]
888+ items : [ { start, explicitKey : true } ]
892889 } as BlockMap
893890 }
894891 case 'map-value-ind' : {
0 commit comments