Skip to content

Commit

Permalink
DisplayTruncator: always apply both limits (sourcegraph#632)
Browse files Browse the repository at this point in the history
If the doc limit was triggered, the match limit was never evaluated,
even if it could have further reduced the FileMatches.
  • Loading branch information
isker authored Aug 1, 2023
1 parent eede122 commit 9559422
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewDisplayTruncator(opts *SearchOptions) (_ DisplayTruncator, hasLimits boo
if docLimited {
if len(fm) >= docLimit {
done = true
return fm[:docLimit], false
fm = fm[:docLimit]
}
docLimit -= len(fm)
}
Expand All @@ -53,11 +53,10 @@ func NewDisplayTruncator(opts *SearchOptions) (_ DisplayTruncator, hasLimits boo
fm, matchLimit = limitMatches(fm, matchLimit, opts.ChunkMatches)
if matchLimit <= 0 {
done = true
return fm, false
}
}

return fm, true
return fm, !done
}, true
}

Expand Down

0 comments on commit 9559422

Please sign in to comment.