From 4147f40ae73f4d842bb9cd205a9ab6103e1592e5 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Tue, 19 Nov 2019 18:03:24 +0900 Subject: [PATCH] Fix handling of literal token include empty line --- parser/parser_test.go | 18 ++++++++++++++++++ scanner/scanner.go | 3 +++ 2 files changed, 21 insertions(+) diff --git a/parser/parser_test.go b/parser/parser_test.go index c3cbc3b0..5577f964 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -414,6 +414,24 @@ a: hoge fuga piyo +`, + }, + { + ` +a: | + bbbbbbb + + + ccccccc +d: eeeeeeeeeeeeeeeee +`, + ` +a: | + bbbbbbb + + + ccccccc +d: eeeeeeeeeeeeeeeee `, }, } diff --git a/scanner/scanner.go b/scanner/scanner.go index 47e9c882..fdcffe87 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -102,6 +102,9 @@ func (s *Scanner) isNeededKeepPreviousIndentNum(ctx *Context, c rune) bool { } func (s *Scanner) updateIndent(ctx *Context, c rune) { + if s.isFirstCharAtLine && c == '\n' && ctx.isDocument() { + return + } if s.isFirstCharAtLine && c == ' ' { s.indentNum++ return