encode: fix commented table with comment (#894)

And updated README.
This commit is contained in:
Thomas Pelletier
2023-08-29 08:46:34 -04:00
committed by GitHub
parent 9dd7f1af78
commit 3175efb395
3 changed files with 61 additions and 7 deletions
+2 -1
View File
@@ -541,6 +541,8 @@ func (enc *Encoder) encodeTableHeader(ctx encoderCtx, b []byte) ([]byte, error)
b = enc.encodeComment(ctx.indent, ctx.options.comment, b)
b = enc.commented(ctx.commented, b)
b = enc.indent(ctx.indent, b)
b = append(b, '[')
@@ -825,7 +827,6 @@ func (enc *Encoder) encodeTable(b []byte, ctx encoderCtx, t table) ([]byte, erro
}
if !ctx.skipTableHeader {
b = enc.commented(ctx.commented, b)
b, err = enc.encodeTableHeader(ctx, b)
if err != nil {
return nil, err