Fix newline after eot behaiour
Change-Id: I4e01088afaa022665635a1382a49eaa70b151e5a
diff --git a/token_writer.go b/token_writer.go
index 39d97fa..250d536 100644
--- a/token_writer.go
+++ b/token_writer.go
@@ -32,6 +32,7 @@
pos := make([]int, 0, 1024)
sentB := true
sent := make([]int, 0, 1024)
+ init := true
tw := &TokenWriter{}
@@ -53,10 +54,12 @@
// and write to string
// Accept newline after EOT
- if flags&NEWLINE_AFTER_EOT != 0 && posC == 0 && buf[0] == '\n' && writer.Buffered() != 0 {
+ if flags&NEWLINE_AFTER_EOT != 0 && posC == 0 && buf[0] == '\n' && !init {
posC--
}
+ init = false
+
posC += offset
pos = append(pos, posC)