summaryrefslogtreecommitdiff
path: root/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
commit06823fbf1c2e763a5bf76c3990ca98fbbcd98691 (patch)
tree4280bece3888d12a022093bf1a9cd1b049393602 /node_modules/yaml/browser/dist/stringify/foldFlowLines.js
parent1368909b3cd552dbb0d12d5863c597f5be46177d (diff)
updated node_modules
Diffstat (limited to 'node_modules/yaml/browser/dist/stringify/foldFlowLines.js')
-rw-r--r--node_modules/yaml/browser/dist/stringify/foldFlowLines.js29
1 files changed, 19 insertions, 10 deletions
diff --git a/node_modules/yaml/browser/dist/stringify/foldFlowLines.js b/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
index 01fe7876..2a554266 100644
--- a/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
+++ b/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
@@ -28,7 +28,7 @@ function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth =
let escStart = -1;
let escEnd = -1;
if (mode === FOLD_BLOCK) {
- i = consumeMoreIndentedLines(text, i);
+ i = consumeMoreIndentedLines(text, i, indent.length);
if (i !== -1)
end = i + endStep;
}
@@ -52,8 +52,8 @@ function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth =
}
if (ch === '\n') {
if (mode === FOLD_BLOCK)
- i = consumeMoreIndentedLines(text, i);
- end = i + endStep;
+ i = consumeMoreIndentedLines(text, i, indent.length);
+ end = i + indent.length + endStep;
split = undefined;
}
else {
@@ -121,15 +121,24 @@ function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth =
* Presumes `i + 1` is at the start of a line
* @returns index of last newline in more-indented block
*/
-function consumeMoreIndentedLines(text, i) {
- let ch = text[i + 1];
+function consumeMoreIndentedLines(text, i, indent) {
+ let end = i;
+ let start = i + 1;
+ let ch = text[start];
while (ch === ' ' || ch === '\t') {
- do {
- ch = text[(i += 1)];
- } while (ch && ch !== '\n');
- ch = text[i + 1];
+ if (i < start + indent) {
+ ch = text[++i];
+ }
+ else {
+ do {
+ ch = text[++i];
+ } while (ch && ch !== '\n');
+ end = i;
+ start = i + 1;
+ ch = text[start];
+ }
}
- return i;
+ return end;
}
export { FOLD_BLOCK, FOLD_FLOW, FOLD_QUOTED, foldFlowLines };