]> Cypherpunks repositories - gostls13.git/commit
text/template: fix pos info when trimming newlines
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 6 Sep 2017 09:57:16 +0000 (11:57 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 7 Sep 2017 14:50:23 +0000 (14:50 +0000)
commit9b8964bf2df0626530a0ca493e3e95d8dc3844dd
tree0444378929758f25f2c10883d9217f7338ed89a4
parent38ad33088c3bee63e8d53e7aff4d6610d82ca84c
text/template: fix pos info when trimming newlines

The lexer keeps the byte offset and the line for the rune it's currently
on. This was simple enough up until whitespace trimming was introduced.

With whitespace trimming, we might skip over newlines. In that case, the
lexer wasn't properly updating the line counter. Fix it.

Also, TestPos now checks that the line is correct too, which it was
ignoring before. This was necessary to test this scenario in the lexer.

Fixes #21778.

Change-Id: I3880f3adf02662eac8f818d5caa6935cca9cb33b
Reviewed-on: https://go-review.googlesource.com/61870
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/text/template/parse/lex.go
src/text/template/parse/lex_test.go