@@ -15,8 +15,11 @@ interface StringifyScalar {
1515 type ?: string
1616}
1717
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 ,
2023 lineWidth : ctx . options . lineWidth ,
2124 minContentWidth : ctx . options . minContentWidth
2225} )
@@ -132,7 +135,7 @@ function doubleQuotedString(value: string, ctx: StringifyContext) {
132135 str = start ? str + json . slice ( start ) : json
133136 return implicitKey
134137 ? str
135- : foldFlowLines ( str , indent , FOLD_QUOTED , getFoldOptions ( ctx ) )
138+ : foldFlowLines ( str , indent , FOLD_QUOTED , getFoldOptions ( ctx , false ) )
136139}
137140
138141function singleQuotedString ( value : string , ctx : StringifyContext ) {
@@ -148,7 +151,7 @@ function singleQuotedString(value: string, ctx: StringifyContext) {
148151 "'" + value . replace ( / ' / g, "''" ) . replace ( / \n + / g, `$&\n${ indent } ` ) + "'"
149152 return ctx . implicitKey
150153 ? res
151- : foldFlowLines ( res , indent , FOLD_FLOW , getFoldOptions ( ctx ) )
154+ : foldFlowLines ( res , indent , FOLD_FLOW , getFoldOptions ( ctx , false ) )
152155}
153156
154157function quotedString ( value : string , ctx : StringifyContext ) {
@@ -254,7 +257,7 @@ function blockString(
254257 `${ start } ${ value } ${ end } ` ,
255258 indent ,
256259 FOLD_BLOCK ,
257- getFoldOptions ( ctx )
260+ getFoldOptions ( ctx , true )
258261 )
259262 return `${ header } \n${ indent } ${ body } `
260263}
@@ -318,7 +321,7 @@ function plainString(
318321 }
319322 return implicitKey
320323 ? str
321- : foldFlowLines ( str , indent , FOLD_FLOW , getFoldOptions ( ctx ) )
324+ : foldFlowLines ( str , indent , FOLD_FLOW , getFoldOptions ( ctx , false ) )
322325}
323326
324327export function stringifyString (
0 commit comments