]> Cypherpunks repositories - gostls13.git/commitdiff
go/printer: correct cindex meaning in commentInfo comments
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Tue, 30 Jul 2024 19:01:10 +0000 (19:01 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 30 Jul 2024 20:12:39 +0000 (20:12 +0000)
(*printer).nextComment increases cindex by one after each call
and it always points to the next element.

Change-Id: I65754ab6e30e10dc7473882e39737d2e0dc29070
GitHub-Last-Rev: f859283324af6ddf9fdc75ef08ee42ae26bc581b
GitHub-Pull-Request: golang/go#68032
Reviewed-on: https://go-review.googlesource.com/c/go/+/592557
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/go/printer/printer.go

index 32be3d67dd7c1d05f8116ebbcacc10216a4a3943..5a6127c6b40dd7a018e3bfd8a575af22a8b83225 100644 (file)
@@ -45,9 +45,9 @@ const (
 )
 
 type commentInfo struct {
-       cindex         int               // current comment index
-       comment        *ast.CommentGroup // = printer.comments[cindex]; or nil
-       commentOffset  int               // = printer.posFor(printer.comments[cindex].List[0].Pos()).Offset; or infinity
+       cindex         int               // index of the next comment
+       comment        *ast.CommentGroup // = printer.comments[cindex-1]; or nil
+       commentOffset  int               // = printer.posFor(printer.comments[cindex-1].List[0].Pos()).Offset; or infinity
        commentNewline bool              // true if the comment group contains newlines
 }