diff --git a/decode_test.go b/decode_test.go index 439988e9..e2115323 100644 --- a/decode_test.go +++ b/decode_test.go @@ -798,6 +798,22 @@ func TestDecoder(t *testing.T) { "---\n", (*struct{})(nil), }, + { + "...", + (*struct{})(nil), + }, + { + "v: go test ./...", + map[string]string{"v": "go test ./..."}, + }, + { + "v: echo ---", + map[string]string{"v": "echo ---"}, + }, + { + "v: |\n hello\n ...\n world\n", + map[string]string{"v": "hello\n...\nworld\n"}, + }, { "a: !!binary gIGC\n", map[string]string{"a": "\x80\x81\x82"}, @@ -975,6 +991,33 @@ c: "c": nil, }, }, + { + `--- +a: go test ./... +b: +c: +`, + map[string]interface{}{ + "a": "go test ./...", + "b": nil, + "c": nil, + }, + }, + { + `--- +a: | + hello + ... + world +b: +c: +`, + map[string]interface{}{ + "a": "hello\n...\nworld\n", + "b": nil, + "c": nil, + }, + }, // Multi bytes { diff --git a/scanner/scanner.go b/scanner/scanner.go index b2d718f6..f1d19c74 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -551,7 +551,7 @@ func (s *Scanner) scan(ctx *Context) (pos int) { return } case '.': - if s.indentNum == 0 && ctx.repeatNum('.') == 3 { + if s.indentNum == 0 && s.column == 1 && ctx.repeatNum('.') == 3 { ctx.addToken(token.DocumentEnd(s.pos())) s.progressColumn(ctx, 3) pos += 2 @@ -566,7 +566,7 @@ func (s *Scanner) scan(ctx *Context) (pos int) { return } case '-': - if s.indentNum == 0 && ctx.repeatNum('-') == 3 { + if s.indentNum == 0 && s.column == 1 && ctx.repeatNum('-') == 3 { s.addBufferedTokenIfExists(ctx) ctx.addToken(token.DocumentHeader(s.pos())) s.progressColumn(ctx, 3)