X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FFilterBuilder.pm;h=823ebf62b02daa93148bec783016dfa8d8f52bca;hb=451b3b302656dab4035e430b0035f027d737a6a2;hp=dc03958b276ea7ccbd9e27dc7b51d3c0e3c62c1a;hpb=76cecb10183d6e452588c98648dfa226a27b8906;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/FilterBuilder.pm b/lib/HTML/Zoom/FilterBuilder.pm index dc03958..823ebf6 100644 --- a/lib/HTML/Zoom/FilterBuilder.pm +++ b/lib/HTML/Zoom/FilterBuilder.pm @@ -168,11 +168,17 @@ sub replace { my ($evt, $stream) = @_; my $emit = $self->_stream_from_array(@$events); my $coll = $self->collect($options)->(@_); + # For a straightforward replace operation we can, in fact, do the emit + # -before- the collect, and my first cut did so. However in order to + # use the captured content in generating the new content, we need + # the collect stage to happen first - and it seems highly unlikely + # that in normal operation the collect phase will take long enough + # for the difference to be noticeable return ($coll ? (ref $coll eq 'ARRAY' - ? [ $coll->[0], $self->_stream_concat($emit, $coll->[1]) ] - : $self->_stream_concat($emit, $coll) + ? [ $coll->[0], $self->_stream_concat($coll->[1], $emit) ] + : $self->_stream_concat($coll, $emit) ) : $emit );