Skip to content

Commit 876e158

Browse files
authored
fix: Stop panicking when the start directive skips directly to the end directive. (#92)
1 parent ee5e55f commit 876e158

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

goldens/skip_lines.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Skip lines with an empty block:
2+
keep-sorted-test start skip_lines=1
3+
keep-sorted-test end
4+
15
Skip two lines:
26
// keep-sorted-test start skip_lines=2
37
foo

goldens/skip_lines.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Skip lines with an empty block:
2+
keep-sorted-test start skip_lines=1
3+
keep-sorted-test end
4+
15
Skip two lines:
26
// keep-sorted-test start skip_lines=2
37
foo

keepsorted/block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (f *Fixer) newBlocks(filename string, lines []string, offset int, include f
114114
}
115115

116116
start.index += opts.SkipLines
117-
if start.index > endIndex {
117+
if start.index >= endIndex {
118118
continue
119119
}
120120

0 commit comments

Comments
 (0)