Skip to content

Commit

Permalink
fix off-by-one
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed Apr 18, 2024
1 parent 40e86e5 commit e402c78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3254,7 +3254,7 @@ func TestLineAnd(t *testing.T) {

t.Run("ChunkMatches", func(t *testing.T) {
res := searchForTest(t, b, &q, chunkOpts)
wantRegexpCount := 2 // TODO: justify this change
wantRegexpCount := 1
if gotRegexpCount := res.RegexpsConsidered; gotRegexpCount != wantRegexpCount {
t.Errorf("got %d, wanted %d", gotRegexpCount, wantRegexpCount)
}
Expand Down
6 changes: 3 additions & 3 deletions matchtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,12 @@ nextLine:
children[j] = children[j][1:]
continue nextCandidate
}
if bo <= lines[i].end {
if bo < lines[i].end {
hits++
continue nextChild
}
// move the `lines` iterator forward until bo <= line.end
for i < len(lines) && bo > lines[i].end {
// move the `lines` iterator forward until bo < line.end
for i < len(lines) && bo >= lines[i].end {
i++
}
i--
Expand Down

0 comments on commit e402c78

Please sign in to comment.