From d826d4392d655a6de2bf1bcf61c6c364226c0869 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 25 Aug 2024 08:54:34 +0200 Subject: [PATCH] initial commit --- yaml/_loader_state.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/yaml/_loader_state.ts b/yaml/_loader_state.ts index 0f8204d8dcdb..29a00704be17 100644 --- a/yaml/_loader_state.ts +++ b/yaml/_loader_state.ts @@ -573,6 +573,13 @@ export class LoaderState { return false; } + writeFoldedLines(count: number) { + if (count === 1) { + this.result += " "; + } else if (count > 1) { + this.result += "\n".repeat(count - 1); + } + } readDocument() { const documentStart = this.position; @@ -700,14 +707,6 @@ export class LoaderState { } } -function writeFoldedLines(state: LoaderState, count: number) { - if (count === 1) { - state.result += " "; - } else if (count > 1) { - state.result += "\n".repeat(count - 1); - } -} - function readPlainScalar( state: LoaderState, nodeIndent: number, @@ -795,7 +794,7 @@ function readPlainScalar( if (hasPendingContent) { state.captureSegment(captureStart, captureEnd, false); - writeFoldedLines(state, state.line - line); + state.writeFoldedLines(state.line - line); captureStart = captureEnd = state.position; hasPendingContent = false; } @@ -851,7 +850,7 @@ function readSingleQuotedScalar( } } else if (isEOL(ch)) { state.captureSegment(captureStart, captureEnd, true); - writeFoldedLines(state, state.skipSeparationSpace(false, nodeIndent)); + state.writeFoldedLines(state.skipSeparationSpace(false, nodeIndent)); captureStart = captureEnd = state.position; } else if ( state.position === state.lineStart && @@ -926,7 +925,7 @@ function readDoubleQuotedScalar( captureStart = captureEnd = state.position; } else if (isEOL(ch)) { state.captureSegment(captureStart, captureEnd, true); - writeFoldedLines(state, state.skipSeparationSpace(false, nodeIndent)); + state.writeFoldedLines(state.skipSeparationSpace(false, nodeIndent)); captureStart = captureEnd = state.position; } else if ( state.position === state.lineStart &&