while ($offset < @$self) {
my $link = substr $self->[$offset], 0, $length;
if ($context) {
- {
+ if ($offset > $context - 1) {
# take a value slightly before the current offset
- my $before = $offset > $context ? $self->[$offset - $context] : '.';
+ my $before = $self->[$offset - $context - 1];
# see how much of it matches the current link
my $trim = 1;
for my $match (split //, $before) {
.-bp bq-dm dn-fi fj-hf hg-i j-k l-m n-os ot-qp qq-sm sn-uj uk-wf wg-x y-
)], 'default ranges');
- is_deeply($index->ranges({pagesize => 300}), [qw(-c d-o p-)], 'large pagesize');
+ is_deeply($index->ranges({pagesize => 300}), [qw(-c d-n o-)], 'large pagesize');
};
subtest 'context' => sub {
qw(-baa. baa.-bbb bbc-daa. daaa-eaa. eaaa-)
], 'no context');
is_deeply($index->ranges({pagesize => 2}), [
- qw(-a b c d-ea. eaa-)
+ qw(-a b c d e-)
], 'default context'); # context should be 1
is_deeply($index->ranges({pagesize => 2, context => 2}), [
qw(-a b-c d e-)
], 'overlap'); # first item equals second due to large context
- is_deeply($index->ranges({pagesize => 2, length => 1}), [
+ is_deeply($index->ranges({pagesize => 2, context => 0, length => 1}), [
qw(-a b-c d e-)
], 'single char');