diff --git a/lib/Biber.pm b/lib/Biber.pm index 7863943b6..7bb668394 100644 --- a/lib/Biber.pm +++ b/lib/Biber.pm @@ -3111,16 +3111,10 @@ sub process_lists { # Filtering - must come before sorting/labelling so that there are no gaps in e.g. extradate if (my $filters = $list->get_filters) { my $flist = []; - my @sets = grep {$section->bibentry($_)->get_field('entrytype') eq 'set'} $list->get_keys->@*; + KEYLOOP: foreach my $k ($list->get_keys->@*) { my $be = $section->bibentry($k); - # Entries that are in a set which is in this list should not be filtered out - if (first {$be->get_field('entryset')} @sets) { - push $flist->@*, $k; - next KEYLOOP - } - foreach my $f ($filters->@*) { # Filter disjunction is ok if any of the checks are ok, hence the grep() if (ref $f eq 'ARRAY') { @@ -3130,8 +3124,22 @@ sub process_lists { next KEYLOOP unless check_list_filter($k, $f->{type}, $f->{value}, $be); } } + push $flist->@*, $k; } + + # Now add set members of sets which have not been filtered out + my @sets = grep {$section->bibentry($_)->get_field('entrytype') eq 'set'} $flist->@*; + foreach my $k ($list->get_keys->@*) { + my $be = $section->bibentry($k); + if (first {$be->get_field('entryset')} @sets) { + push $flist->@*, $k; + } + } + + # $flist now has the filtered list keys, possibly with duplicates due to sets so uniqify + $flist->@* = uniq $flist->@*; + if ($logger->is_debug()) { # performance tune $logger->debug("Keys after filtering list '$lname' in section $secnum: " . join(', ', $flist->@*)); } diff --git a/t/set-static.t b/t/set-static.t index fe5cd1a5e..a76ad2943 100644 --- a/t/set-static.t +++ b/t/set-static.t @@ -49,6 +49,7 @@ my $string1 = q| \entry{Static1}{set}{}{} \field{sortinit}{B} \field{sortinithash}{d7095fff47cda75ca2589920aae98399} \field{annotation}{Some notes} + \field{shorthand}{STAT1} \endentry |; @@ -179,4 +180,4 @@ is_deeply($biber->datalists->get_lists_by_attrs(section => 0, labelprefix => '', uniquenametemplatename => 'global', labelalphanametemplatename => 'global', - namehashtemplatename => 'global')->[0]->get_keys, ['Static2', 'Static1', 'Static3', 'Static4'], 'Shorthand - sets'); + namehashtemplatename => 'global')->[0]->get_keys, ['Static2', 'Static3', 'Static4', 'Static1'], 'Shorthand - sets'); diff --git a/t/tdata/sets.bib b/t/tdata/sets.bib index 895c03e84..9ccc0d31a 100644 --- a/t/tdata/sets.bib +++ b/t/tdata/sets.bib @@ -36,6 +36,7 @@ @ARTICLE{Elias1955b @SET{Static1, ENTRYSET = {Static2alias, Static3, Static4, missing1}, + SHORTHAND = {STAT1}, ANNOTATION = {Some notes} }