Fix: filter_entry misbehaves when contents_first is enabled #198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
filter_entry
misbehaves whencontents_first
is enabled #171Proposed changes
IntoIter::skip_current_dir_unless_contents_first
FilterEntry::next
callskip_current_dir_unless_contents_first
instead ofskip_current_dir
if the skipped entry is a directoryfilter_entry
andcontents_first
Details
The documentation of
IntoIter::filter_entry
states that:However, if
contents_first
was enabled and some directories were filtered out, unexpected entries may have been skipped regardless of thefilter_entry
results. Please refer to #171 for an example.FilterEntry::next
used to callskip_current_dir
when the filtered out entry was a directory to stop reading the filtered out directory.skip_current_dir
realizes this by popping the lastDirList
fromstack_list
. Unfortunately, ifcontents_first
was enabled,skip_current_dir
popped a wrongDirList
fromstack_list
, because theDirList
of the filtered out directory had already been removed fromstack_list
.We should not update
stack_list
ifcontents_first
is enabled. So I introducedskip_current_dir_unless_contents_first
which does nothing ifcontents_first
is enabled, otherwise callsskip_current_dir
.