Skip to content

Commit bf7312d

Browse files
committed
Fix wrong number of lines reported
Signed-off-by: apostasie <[email protected]>
1 parent d668068 commit bf7312d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mod/tigron/internal/formatter/formatter.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,21 @@ func chunk(s string, maxLength, maxLines int) []string {
108108
}
109109

110110
// If really long, preserve the starting first quarter, the trailing three quarters, and inform.
111-
if len(chunks) > maxLines {
112-
abbreviator := fmt.Sprintf("... %d lines are being ignored...", len(chunks)-maxLines)
111+
actualLength := len(chunks)
112+
if actualLength > maxLines {
113+
abbreviator := fmt.Sprintf("... %d lines are being ignored...", actualLength-maxLines)
113114
chunks = append(
114115
append(chunks[0:maxLines/4], abbreviator+strings.Repeat(spacer, maxLength-len(abbreviator))),
115-
chunks[len(chunks)-maxLines*3/4:]...,
116+
chunks[actualLength-maxLines*3/4:]...,
116117
)
117118
chunks = append(
118119
[]string{
119-
fmt.Sprintf("Actual content is %d lines long and has been abbreviated to %d\n", len(chunks), maxLines),
120+
fmt.Sprintf("Actual content is %d lines long and has been abbreviated to %d\n", actualLength, maxLines),
120121
strings.Repeat(spacer, maxLength),
121122
},
122123
chunks...,
123124
)
124-
} else if len(chunks) == 0 {
125+
} else if actualLength == 0 {
125126
chunks = []string{strings.Repeat(spacer, maxLength)}
126127
}
127128

0 commit comments

Comments
 (0)