@@ -15,8 +15,11 @@ interface StringifyScalar {
15
15
type ?: string
16
16
}
17
17
18
- const getFoldOptions = ( ctx : StringifyContext ) : FoldOptions => ( {
19
- indentAtStart : ctx . indentAtStart ,
18
+ const getFoldOptions = (
19
+ ctx : StringifyContext ,
20
+ isBlock : boolean
21
+ ) : FoldOptions => ( {
22
+ indentAtStart : isBlock ? ctx . indent . length : ctx . indentAtStart ,
20
23
lineWidth : ctx . options . lineWidth ,
21
24
minContentWidth : ctx . options . minContentWidth
22
25
} )
@@ -132,7 +135,7 @@ function doubleQuotedString(value: string, ctx: StringifyContext) {
132
135
str = start ? str + json . slice ( start ) : json
133
136
return implicitKey
134
137
? str
135
- : foldFlowLines ( str , indent , FOLD_QUOTED , getFoldOptions ( ctx ) )
138
+ : foldFlowLines ( str , indent , FOLD_QUOTED , getFoldOptions ( ctx , false ) )
136
139
}
137
140
138
141
function singleQuotedString ( value : string , ctx : StringifyContext ) {
@@ -148,7 +151,7 @@ function singleQuotedString(value: string, ctx: StringifyContext) {
148
151
"'" + value . replace ( / ' / g, "''" ) . replace ( / \n + / g, `$&\n${ indent } ` ) + "'"
149
152
return ctx . implicitKey
150
153
? res
151
- : foldFlowLines ( res , indent , FOLD_FLOW , getFoldOptions ( ctx ) )
154
+ : foldFlowLines ( res , indent , FOLD_FLOW , getFoldOptions ( ctx , false ) )
152
155
}
153
156
154
157
function quotedString ( value : string , ctx : StringifyContext ) {
@@ -254,7 +257,7 @@ function blockString(
254
257
`${ start } ${ value } ${ end } ` ,
255
258
indent ,
256
259
FOLD_BLOCK ,
257
- getFoldOptions ( ctx )
260
+ getFoldOptions ( ctx , true )
258
261
)
259
262
return `${ header } \n${ indent } ${ body } `
260
263
}
@@ -318,7 +321,7 @@ function plainString(
318
321
}
319
322
return implicitKey
320
323
? str
321
- : foldFlowLines ( str , indent , FOLD_FLOW , getFoldOptions ( ctx ) )
324
+ : foldFlowLines ( str , indent , FOLD_FLOW , getFoldOptions ( ctx , false ) )
322
325
}
323
326
324
327
export function stringifyString (
0 commit comments