diff --git a/parser/parser_test.go b/parser/parser_test.go index f9218b75..6bb85683 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -128,6 +128,11 @@ a: !tag a: !tag b: c d: e +`, + ` +a: + b: c + `, } for _, src := range sources { diff --git a/scanner/context.go b/scanner/context.go index f6c06e19..7c5517d8 100644 --- a/scanner/context.go +++ b/scanner/context.go @@ -198,7 +198,7 @@ func (c *Context) addOriginBuf(r rune) { } } -func (c *Context) removeRightSpaceFromBuf() int { +func (c *Context) removeRightSpaceFromBuf() { trimmedBuf := c.obuf[:c.notSpaceOrgCharPos] buflen := len(trimmedBuf) diff := len(c.obuf) - buflen @@ -206,7 +206,6 @@ func (c *Context) removeRightSpaceFromBuf() int { c.obuf = c.obuf[:buflen] c.buf = c.bufferedSrc() } - return diff } func (c *Context) isDocument() bool { diff --git a/scanner/scanner.go b/scanner/scanner.go index 50e24b1a..f1d27743 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -623,14 +623,7 @@ func (s *Scanner) scanNewLine(ctx *Context, c rune) { // --- // a:[space][space] // b: c - removedNum := ctx.removeRightSpaceFromBuf() - if removedNum > 0 { - s.column -= removedNum - s.offset -= removedNum - if s.savedPos != nil { - s.savedPos.Column -= removedNum - } - } + ctx.removeRightSpaceFromBuf() // There is no problem that we ignore CR which followed by LF and normalize it to LF, because of following YAML1.2 spec. // > Line breaks inside scalar content must be normalized by the YAML processor. Each such line break must be parsed into a single line feed character.