glob-object icon indicating copy to clipboard operation
glob-object copied to clipboard

skipped patterns when multiple negations exists

Open doowb opened this issue 8 years ago • 2 comments

The example from this filter-object issue shows that some of the patterns are being skipped when there are multiple negation patterns.

This line just needs to be updated to patterns.splice(1, i--); so the i is "fixed" after the splicing happens.

@kilianc I'll try to get to this, but if you can do a PR first, we'd appreciate it. Thanks!

doowb avatar Aug 22 '17 03:08 doowb

@doowb patterns.splice(1, i--); would result in an infinite loop. I think it's a bad idea to alter the index in a for loop :/

kilianc avatar Aug 22 '17 04:08 kilianc

Not in this case, because patterns.splice(1, i) is removing an item, then the i++ in the for loop effectively skips the next item in the patterns array. Adding the i-- just makes up for making the patterns array shorter.

I tried it locally and it returned the expected results with your example. I just didn't have the time tonight to update the tests for this use case.

doowb avatar Aug 22 '17 04:08 doowb