Skip to content

Commit

Permalink
check for underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed Apr 18, 2024
1 parent a91d71f commit 804d888
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contentprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (p *contentProvider) fillContentChunkMatches(ms []*candidateMatch, numConte
// We want the line of the last byte in the match, not the first byte outside of the match.
// For a zero-length match, endOffset-1 could be before match start, so fall back to the
// byte after the match (as we do for startLine), not before.
max(startOffset, endOffset-1),
max(startOffset, max(endOffset, 1)-1 /* prevent underflow */),
)

ranges = append(ranges, Range{
Expand Down

0 comments on commit 804d888

Please sign in to comment.