Skip to content

Commit 5ac2581

Browse files
committed
Add a local variable
1 parent a9cc75f commit 5ac2581

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

hooks/jsonnet-fmt-hook/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func summarizeDiff(diffs []diffmatchpatch.Diff) *FileDiff {
8181

8282
const maxShowLine = 3
8383
const omissionText = "...\n"
84+
lastDiffIdx := len(diffs) - 1
8485

8586
for i, diff := range diffs {
8687
text := diff.Text
@@ -100,7 +101,7 @@ func summarizeDiff(diffs []diffmatchpatch.Diff) *FileDiff {
100101

101102
if i == 0 {
102103
showTail = true
103-
} else if i == (len(diffs) - 1) {
104+
} else if i == lastDiffIdx {
104105
showHead = true
105106
} else {
106107
showTail = true

0 commit comments

Comments
 (0)