From 208e32895124290d06d0d47b877ab904b4fa79ac Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Fri, 8 Nov 2019 01:04:29 +0900 Subject: [PATCH] Include indent to literal token --- scanner/scanner.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scanner/scanner.go b/scanner/scanner.go index e11418e3..da73fced 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -34,6 +34,7 @@ type Scanner struct { prevIndentLevel int prevIndentNum int prevIndentColumn int + docStartColumn int indentLevel int indentNum int isFirstCharAtLine bool @@ -158,6 +159,7 @@ func (s *Scanner) addBufferedTokenIfExists(ctx *Context) { } func (s *Scanner) breakLiteral(ctx *Context) { + s.docStartColumn = 0 ctx.breakLiteral() } @@ -238,8 +240,14 @@ func (s *Scanner) scanLiteral(ctx *Context, c rune) { } s.progressLine(ctx) } else if s.isFirstCharAtLine && c == ' ' { + if 0 < s.docStartColumn && s.docStartColumn <= s.column { + ctx.addBuf(c) + } s.progressColumn(ctx, 1) } else { + if s.docStartColumn == 0 { + s.docStartColumn = s.column + } ctx.addBuf(c) s.progressColumn(ctx, 1) }