Comparing version 2.2.1 to 2.2.2
@@ -50,3 +50,3 @@ class YAMLError extends Error { | ||
if (end && end.line === line && end.col > col) { | ||
count = Math.min(end.col - col, 80 - ci); | ||
count = Math.max(1, Math.min(end.col - col, 80 - ci)); | ||
} | ||
@@ -53,0 +53,0 @@ const pointer = ' '.repeat(ci) + '^'.repeat(count); |
@@ -136,3 +136,3 @@ import { Collection } from '../nodes/Collection.js'; | ||
if (comment) { | ||
str += lineComment(str, commentString(comment), indent); | ||
str += lineComment(str, indent, commentString(comment)); | ||
if (onComment) | ||
@@ -139,0 +139,0 @@ onComment(); |
import { Scalar } from '../nodes/Scalar.js'; | ||
import { foldFlowLines, FOLD_QUOTED, FOLD_FLOW, FOLD_BLOCK } from './foldFlowLines.js'; | ||
const getFoldOptions = (ctx) => ({ | ||
indentAtStart: ctx.indentAtStart, | ||
const getFoldOptions = (ctx, isBlock) => ({ | ||
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart, | ||
lineWidth: ctx.options.lineWidth, | ||
@@ -118,3 +118,3 @@ minContentWidth: ctx.options.minContentWidth | ||
? str | ||
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx)); | ||
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx, false)); | ||
} | ||
@@ -131,3 +131,3 @@ function singleQuotedString(value, ctx) { | ||
? res | ||
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx)); | ||
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx, false)); | ||
} | ||
@@ -230,3 +230,3 @@ function quotedString(value, ctx) { | ||
.replace(/\n+/g, `$&${indent}`); | ||
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx)); | ||
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true)); | ||
return `${header}\n${indent}${body}`; | ||
@@ -281,3 +281,3 @@ } | ||
? str | ||
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx)); | ||
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx, false)); | ||
} | ||
@@ -284,0 +284,0 @@ function stringifyString(item, ctx, onComment, onChompKeep) { |
@@ -52,3 +52,3 @@ 'use strict'; | ||
if (end && end.line === line && end.col > col) { | ||
count = Math.min(end.col - col, 80 - ci); | ||
count = Math.max(1, Math.min(end.col - col, 80 - ci)); | ||
} | ||
@@ -55,0 +55,0 @@ const pointer = ' '.repeat(ci) + '^'.repeat(count); |
@@ -138,3 +138,3 @@ 'use strict'; | ||
if (comment) { | ||
str += stringifyComment.lineComment(str, commentString(comment), indent); | ||
str += stringifyComment.lineComment(str, indent, commentString(comment)); | ||
if (onComment) | ||
@@ -141,0 +141,0 @@ onComment(); |
@@ -6,4 +6,4 @@ 'use strict'; | ||
const getFoldOptions = (ctx) => ({ | ||
indentAtStart: ctx.indentAtStart, | ||
const getFoldOptions = (ctx, isBlock) => ({ | ||
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart, | ||
lineWidth: ctx.options.lineWidth, | ||
@@ -121,3 +121,3 @@ minContentWidth: ctx.options.minContentWidth | ||
? str | ||
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx)); | ||
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false)); | ||
} | ||
@@ -134,3 +134,3 @@ function singleQuotedString(value, ctx) { | ||
? res | ||
: foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx)); | ||
: foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false)); | ||
} | ||
@@ -233,3 +233,3 @@ function quotedString(value, ctx) { | ||
.replace(/\n+/g, `$&${indent}`); | ||
const body = foldFlowLines.foldFlowLines(`${start}${value}${end}`, indent, foldFlowLines.FOLD_BLOCK, getFoldOptions(ctx)); | ||
const body = foldFlowLines.foldFlowLines(`${start}${value}${end}`, indent, foldFlowLines.FOLD_BLOCK, getFoldOptions(ctx, true)); | ||
return `${header}\n${indent}${body}`; | ||
@@ -284,3 +284,3 @@ } | ||
? str | ||
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx)); | ||
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false)); | ||
} | ||
@@ -287,0 +287,0 @@ function stringifyString(item, ctx, onComment, onChompKeep) { |
{ | ||
"name": "yaml", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "Eemeli Aro <eemeli@gmail.com>", |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
651576
0