@@ -43,19 +43,40 @@ function resolveCollection(
43
43
return coll
44
44
}
45
45
46
+ interface Props {
47
+ anchor : SourceToken | null
48
+ tag : SourceToken | null
49
+ newlineAfterProp : SourceToken | null
50
+ }
51
+
46
52
export function composeCollection (
47
53
CN : ComposeNode ,
48
54
ctx : ComposeContext ,
49
55
token : BlockMap | BlockSequence | FlowCollection ,
50
- tagToken : SourceToken | null ,
56
+ props : Props ,
51
57
onError : ComposeErrorHandler
52
58
) {
59
+ const tagToken = props . tag
53
60
const tagName : string | null = ! tagToken
54
61
? null
55
62
: ctx . directives . tagName ( tagToken . source , msg =>
56
63
onError ( tagToken , 'TAG_RESOLVE_FAILED' , msg )
57
64
)
58
65
66
+ if ( token . type === 'block-seq' ) {
67
+ const { anchor, newlineAfterProp : nl } = props
68
+ const lastProp =
69
+ anchor && tagToken
70
+ ? anchor . offset > tagToken . offset
71
+ ? anchor
72
+ : tagToken
73
+ : anchor ?? tagToken
74
+ if ( lastProp && ( ! nl || nl . offset < lastProp . offset ) ) {
75
+ const message = 'Missing newline after block sequence props'
76
+ onError ( lastProp , 'MISSING_CHAR' , message )
77
+ }
78
+ }
79
+
59
80
const expType : 'map' | 'seq' =
60
81
token . type === 'block-map'
61
82
? 'map'
@@ -72,8 +93,7 @@ export function composeCollection(
72
93
! tagName ||
73
94
tagName === '!' ||
74
95
( tagName === YAMLMap . tagName && expType === 'map' ) ||
75
- ( tagName === YAMLSeq . tagName && expType === 'seq' ) ||
76
- ! expType
96
+ ( tagName === YAMLSeq . tagName && expType === 'seq' )
77
97
) {
78
98
return resolveCollection ( CN , ctx , token , onError , tagName )
79
99
}
0 commit comments