From da0abe45951c1538aa68d222b5d703f441d1059e Mon Sep 17 00:00:00 2001 From: tsingbx Date: Wed, 25 Sep 2024 10:29:25 +0800 Subject: [PATCH] modify stripCommonPrefix to fix panic --- internal/go/printer/printer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/go/printer/printer.go b/internal/go/printer/printer.go index a4897835..a2b9582f 100644 --- a/internal/go/printer/printer.go +++ b/internal/go/printer/printer.go @@ -609,7 +609,7 @@ func stripCommonPrefix(lines []string) { last := lines[len(lines)-1] closing := "*/" i := strings.Index(last, closing) // i >= 0 (closing is always present) - if isBlank(last[0:i]) { + if i >= 0 && isBlank(last[0:i]) { // last line only contains closing */ if lineOfStars { closing = " */" // add blank to align final star