npm package diff

Package: yaml

Versions: 2.2.1 - 2.2.2

Modified:package/browser/dist/errors.js

Index: package/browser/dist/errors.js
===================================================================
--- package/browser/dist/errors.js
+++ package/browser/dist/errors.js
@@ -46,9 +46,9 @@
     if (/[^ ]/.test(lineStr)) {
         let count = 1;
         const end = error.linePos[1];
         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));
         }
         const pointer = ' '.repeat(ci) + '^'.repeat(count);
         error.message += `:\n\n${lineStr}\n${pointer}\n`;
     }

Modified:package/dist/errors.js

Index: package/dist/errors.js
===================================================================
--- package/dist/errors.js
+++ package/dist/errors.js
@@ -48,9 +48,9 @@
     if (/[^ ]/.test(lineStr)) {
         let count = 1;
         const end = error.linePos[1];
         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));
         }
         const pointer = ' '.repeat(ci) + '^'.repeat(count);
         error.message += `:\n\n${lineStr}\n${pointer}\n`;
     }

Modified:package/browser/dist/stringify/stringifyCollection.js

Index: package/browser/dist/stringify/stringifyCollection.js
===================================================================
--- package/browser/dist/stringify/stringifyCollection.js
+++ package/browser/dist/stringify/stringifyCollection.js
@@ -132,9 +132,9 @@
             str = `${start}${fcPadding}${lines.join(' ')}${fcPadding}${end}`;
         }
     }
     if (comment) {
-        str += lineComment(str, commentString(comment), indent);
+        str += lineComment(str, indent, commentString(comment));
         if (onComment)
             onComment();
     }
     return str;

Modified:package/dist/stringify/stringifyCollection.js

Index: package/dist/stringify/stringifyCollection.js
===================================================================
--- package/dist/stringify/stringifyCollection.js
+++ package/dist/stringify/stringifyCollection.js
@@ -134,9 +134,9 @@
             str = `${start}${fcPadding}${lines.join(' ')}${fcPadding}${end}`;
         }
     }
     if (comment) {
-        str += stringifyComment.lineComment(str, commentString(comment), indent);
+        str += stringifyComment.lineComment(str, indent, commentString(comment));
         if (onComment)
             onComment();
     }
     return str;

Modified:package/browser/dist/stringify/stringifyString.js

Index: package/browser/dist/stringify/stringifyString.js
===================================================================
--- package/browser/dist/stringify/stringifyString.js
+++ package/browser/dist/stringify/stringifyString.js
@@ -1,9 +1,9 @@
 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,
     minContentWidth: ctx.options.minContentWidth
 });
 // Also checks for lines starting with %, as parsing the output as YAML 1.1 will
@@ -114,9 +114,9 @@
     }
     str = start ? str + json.slice(start) : json;
     return implicitKey
         ? str
-        : foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx));
+        : foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx, false));
 }
 function singleQuotedString(value, ctx) {
     if (ctx.options.singleQuote === false ||
         (ctx.implicitKey && value.includes('\n')) ||
@@ -126,9 +126,9 @@
     const indent = ctx.indent || (containsDocumentMarker(value) ? '  ' : '');
     const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
     return ctx.implicitKey
         ? res
-        : foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx));
+        : foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx, false));
 }
 function quotedString(value, ctx) {
     const { singleQuote } = ctx.options;
     let qs;
@@ -224,9 +224,9 @@
         .replace(/\n+/g, '\n$&')
         .replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
         //                ^ more-ind. ^ empty     ^ capture next empty lines only at end of indent
         .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}`;
 }
 function plainString(item, ctx, onComment, onChompKeep) {
     const { type, value } = item;
@@ -274,9 +274,9 @@
             return quotedString(value, ctx);
     }
     return implicitKey
         ? str
-        : foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx));
+        : foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx, false));
 }
 function stringifyString(item, ctx, onComment, onChompKeep) {
     const { implicitKey, inFlow } = ctx;
     const ss = typeof item.value === 'string'

Modified:package/dist/stringify/stringifyString.js

Index: package/dist/stringify/stringifyString.js
===================================================================
--- package/dist/stringify/stringifyString.js
+++ package/dist/stringify/stringifyString.js
@@ -2,10 +2,10 @@
 
 var Scalar = require('../nodes/Scalar.js');
 var foldFlowLines = require('./foldFlowLines.js');
 
-const getFoldOptions = (ctx) => ({
-    indentAtStart: ctx.indentAtStart,
+const getFoldOptions = (ctx, isBlock) => ({
+    indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
     lineWidth: ctx.options.lineWidth,
     minContentWidth: ctx.options.minContentWidth
 });
 // Also checks for lines starting with %, as parsing the output as YAML 1.1 will
@@ -116,9 +116,9 @@
     }
     str = start ? str + json.slice(start) : json;
     return implicitKey
         ? str
-        : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx));
+        : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
 }
 function singleQuotedString(value, ctx) {
     if (ctx.options.singleQuote === false ||
         (ctx.implicitKey && value.includes('\n')) ||
@@ -128,9 +128,9 @@
     const indent = ctx.indent || (containsDocumentMarker(value) ? '  ' : '');
     const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
     return ctx.implicitKey
         ? res
-        : foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
+        : foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
 }
 function quotedString(value, ctx) {
     const { singleQuote } = ctx.options;
     let qs;
@@ -226,9 +226,9 @@
         .replace(/\n+/g, '\n$&')
         .replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
         //                ^ more-ind. ^ empty     ^ capture next empty lines only at end of indent
         .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}`;
 }
 function plainString(item, ctx, onComment, onChompKeep) {
     const { type, value } = item;
@@ -276,9 +276,9 @@
             return quotedString(value, ctx);
     }
     return implicitKey
         ? str
-        : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
+        : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
 }
 function stringifyString(item, ctx, onComment, onChompKeep) {
     const { implicitKey, inFlow } = ctx;
     const ss = typeof item.value === 'string'

Modified:package/package.json

Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
 {
   "name": "yaml",
-  "version": "2.2.1",
+  "version": "2.2.2",
   "license": "ISC",
   "author": "Eemeli Aro <[email protected]>",
   "repository": "github:eemeli/yaml",
   "description": "JavaScript parser and stringifier for YAML",