Skip to content

Commit

Permalink
Include indent to literal token
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Nov 7, 2019
1 parent c61d2c3 commit 208e328
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Scanner struct {
prevIndentLevel int
prevIndentNum int
prevIndentColumn int
docStartColumn int
indentLevel int
indentNum int
isFirstCharAtLine bool
Expand Down Expand Up @@ -158,6 +159,7 @@ func (s *Scanner) addBufferedTokenIfExists(ctx *Context) {
}

func (s *Scanner) breakLiteral(ctx *Context) {
s.docStartColumn = 0
ctx.breakLiteral()
}

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 208e328

Please sign in to comment.