Skip to content

Commit 81de1a2

Browse files
committed
fix: improve logic for displaying diff summary in jsonnet formatter
1 parent e9aaa6f commit 81de1a2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hooks/jsonnet-fmt-hook/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,12 @@ func summarizeDiff(diffs []diffmatchpatch.Diff) *FileDiff {
9999
endWithLineBreak = text[len(text)-1:] == "\n"
100100
writeLineCount := min(maxShowLine, len(lines))
101101

102-
if i == 0 {
102+
switch i {
103+
case 0:
103104
showTail = true
104-
} else if i == lastDiffIdx {
105+
case lastDiffIdx:
105106
showHead = true
106-
} else {
107+
default:
107108
showTail = true
108109
showHead = true
109110
}

0 commit comments

Comments
 (0)