@@ -64585,10 +64585,23 @@ function resolveCollection(CN, ctx, token, onError, tagName, tag) {
64585
64585
coll.tag = tagName;
64586
64586
return coll;
64587
64587
}
64588
- function composeCollection(CN, ctx, token, tagToken, onError) {
64588
+ function composeCollection(CN, ctx, token, props, onError) {
64589
+ const tagToken = props.tag;
64589
64590
const tagName = !tagToken
64590
64591
? null
64591
64592
: ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
64593
+ if (token.type === 'block-seq') {
64594
+ const { anchor, newlineAfterProp: nl } = props;
64595
+ const lastProp = anchor && tagToken
64596
+ ? anchor.offset > tagToken.offset
64597
+ ? anchor
64598
+ : tagToken
64599
+ : (anchor ?? tagToken);
64600
+ if (lastProp && (!nl || nl.offset < lastProp.offset)) {
64601
+ const message = 'Missing newline after block sequence props';
64602
+ onError(lastProp, 'MISSING_CHAR', message);
64603
+ }
64604
+ }
64592
64605
const expType = token.type === 'block-map'
64593
64606
? 'map'
64594
64607
: token.type === 'block-seq'
@@ -64602,8 +64615,7 @@ function composeCollection(CN, ctx, token, tagToken, onError) {
64602
64615
!tagName ||
64603
64616
tagName === '!' ||
64604
64617
(tagName === YAMLMap.YAMLMap.tagName && expType === 'map') ||
64605
- (tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq') ||
64606
- !expType) {
64618
+ (tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq')) {
64607
64619
return resolveCollection(CN, ctx, token, onError, tagName);
64608
64620
}
64609
64621
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
@@ -64726,7 +64738,7 @@ function composeNode(ctx, token, props, onError) {
64726
64738
case 'block-map':
64727
64739
case 'block-seq':
64728
64740
case 'flow-collection':
64729
- node = composeCollection.composeCollection(CN, ctx, token, tag , onError);
64741
+ node = composeCollection.composeCollection(CN, ctx, token, props , onError);
64730
64742
if (anchor)
64731
64743
node.anchor = anchor.source.substring(1);
64732
64744
break;
@@ -65164,7 +65176,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
65164
65176
}
65165
65177
continue;
65166
65178
}
65167
- if (keyProps.hasNewlineAfterProp || utilContainsNewline.containsNewline(key)) {
65179
+ if (keyProps.newlineAfterProp || utilContainsNewline.containsNewline(key)) {
65168
65180
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
65169
65181
}
65170
65182
}
@@ -66006,11 +66018,11 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
66006
66018
let comment = '';
66007
66019
let commentSep = '';
66008
66020
let hasNewline = false;
66009
- let hasNewlineAfterProp = false;
66010
66021
let reqSpace = false;
66011
66022
let tab = null;
66012
66023
let anchor = null;
66013
66024
let tag = null;
66025
+ let newlineAfterProp = null;
66014
66026
let comma = null;
66015
66027
let found = null;
66016
66028
let start = null;
@@ -66064,7 +66076,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
66064
66076
atNewline = true;
66065
66077
hasNewline = true;
66066
66078
if (anchor || tag)
66067
- hasNewlineAfterProp = true ;
66079
+ newlineAfterProp = token ;
66068
66080
hasSpace = true;
66069
66081
break;
66070
66082
case 'anchor':
@@ -66138,9 +66150,9 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
66138
66150
spaceBefore,
66139
66151
comment,
66140
66152
hasNewline,
66141
- hasNewlineAfterProp,
66142
66153
anchor,
66143
66154
tag,
66155
+ newlineAfterProp,
66144
66156
end,
66145
66157
start: start ?? end
66146
66158
};
@@ -67479,7 +67491,6 @@ class Collection extends Node.NodeBase {
67479
67491
}
67480
67492
}
67481
67493
}
67482
- Collection.maxFlowStringSingleLineLength = 60;
67483
67494
67484
67495
exports.Collection = Collection;
67485
67496
exports.collectionFromPath = collectionFromPath;
@@ -68940,15 +68951,11 @@ class Lexer {
68940
68951
if (!this.atEnd && !this.hasChars(4))
68941
68952
return this.setNext('line-start');
68942
68953
const s = this.peek(3);
68943
- if (s === '---' && isEmpty(this.charAt(3))) {
68954
+ if (( s === '---' || s === '...') && isEmpty(this.charAt(3))) {
68944
68955
yield* this.pushCount(3);
68945
68956
this.indentValue = 0;
68946
68957
this.indentNext = 0;
68947
- return 'doc';
68948
- }
68949
- else if (s === '...' && isEmpty(this.charAt(3))) {
68950
- yield* this.pushCount(3);
68951
- return 'stream';
68958
+ return s === '---' ? 'doc' : 'stream';
68952
68959
}
68953
68960
}
68954
68961
this.indentValue = yield* this.pushSpaces(false);
@@ -71693,6 +71700,8 @@ const FOLD_QUOTED = 'quoted';
71693
71700
function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
71694
71701
if (!lineWidth || lineWidth < 0)
71695
71702
return text;
71703
+ if (lineWidth < minContentWidth)
71704
+ minContentWidth = 0;
71696
71705
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
71697
71706
if (text.length <= endStep)
71698
71707
return text;
0 commit comments