Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions keepsorted/line_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,13 @@ func groupLines(lines []string, metadata blockMetadata) []*lineGroup {
finishGroup()
}

if metadata.opts.Group && strings.Contains(l, metadata.startDirective) {
// We don't need to check for end directives here because this makes
// numUnmatchedStartDirectives > 0, so we'll take the code path above through appendLine.
if lineRange.empty() {
commentRange.append(i)
countStartDirectives(l)
} else {
appendLine(i, l)
}
} else {
commentRange.append(i)
commentRange.append(i)
if metadata.opts.Group {
// Note: This will not count end directives. If this call ever finds a
// start directive, it will set numUnmatchedStartDirectives > 0 and then
// we will enter the branch above where we'll count end directives via
// its appendLine call.
countStartDirectives(l)
}
} else {
if !lineRange.empty() {
Expand Down