repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 715135dbaf7d156ae275dd5cbc41917030090c6a: path_to: revision_to:
commit 715135dbaf7d156ae275dd5cbc41917030090c6a Author: Emanuele GiaquintaDate: Sat Jun 7 20:07:38 2014 +0000 Make matcher:list really compute the 10 'most recent' matches. diff --git a/src/perl/matcher b/src/perl/matcher
--- a/src/perl/matcher
+++ b/src/perl/matcher
@@ -104,6 +104,7 @@ sub matchlist {
my $text = $line->t;
# FIXME: code duplicated from 'command_for'
+ my @matches;
for my $matcher (@{$self->{matchers}}) {
my $launcher = $matcher->[1] || $self->{launcher};
while ($text =~ /$matcher->[0]/g) {
@@ -120,10 +121,16 @@ sub matchlist {
/egx; $_ } split /\s+/, $launcher;
}
- push @{ $self->{matches} }, [ $match, @exec ];
+ push @matches, [ $beg[0], $match, @exec ];
}
}
+ for (sort { $b->[0] <=> $a->[0] } @matches) {
+ shift @$_;
+ push @{ $self->{matches} }, $_;
+ last if @{ $self->{matches} } == 10;
+ }
+
$row = $line->beg - 1;
}
-----END OF PAGE-----