X-Git-Url: http://git.shiar.net/perl/list-index.git/blobdiff_plain/d6c30ef4ef400982bc1b08e9b7bf93993ea29be5..319dd675faee700a9fa0485863889a661ef9dc53:/lib/List/Index.pm diff --git a/lib/List/Index.pm b/lib/List/Index.pm index c42db44..00f2bdb 100644 --- a/lib/List/Index.pm +++ b/lib/List/Index.pm @@ -29,7 +29,7 @@ sub ranges { my $link = substr $self->[$offset], 0, $length; if ($context) { my $trim = 1; - my $before = $offset > $context ? $self->[$offset - $context] : ''; + my $before = $offset > $context ? $self->[$offset - $context] : '.'; for my $match (split //, $before) { scalar $link =~ /\G\Q$match/g or last; $trim++; @@ -43,8 +43,9 @@ sub ranges { for my $i (0 .. $#links - 1) { my ($link, $lastchar) = $links[$i + 1]->[0] =~ /(.*)(.)/; - $link .= $lastchar eq '.' ? 'a' : chr( ord($lastchar) - 1 ) - unless $lastchar eq 'a'; + $link .= $lastchar eq 'a' ? '.' : chr( ord($lastchar) - 1 ) + unless $lastchar eq '.'; + next if $link eq $links[$i]->[0]; $links[$i]->[1] = $link; } $links[-1]->[1] = '';