fix: set negatedExtGlob also if it does not span the whole pattern · micromatch/picomatch@032e3f5 (original) (raw)

Original file line number Diff line number Diff line change
@@ -247,7 +247,7 @@ const parse = (input, options) => {
247 247 output = token.close = `)$))${extglobStar}`;
248 248 }
249 249
250 -if (token.prev.type === 'bos' && eos()) {
250 +if (token.prev.type === 'bos') {
251 251 state.negatedExtglob = true;
252 252 }
253 253 }
Original file line number Diff line number Diff line change
@@ -347,4 +347,19 @@ describe('picomatch', () => {
347 347 });
348 348 });
349 349 });
350 +
351 +describe('state', () => {
352 +describe('negatedExtglob', () => {
353 +it('should return true', () => {
354 +assert(picomatch('!(abc)', {}, true).state.negatedExtglob);
355 +assert(picomatch('!(abc)**', {}, true).state.negatedExtglob);
356 +assert(picomatch('!(abc)/**', {}, true).state.negatedExtglob);
357 +});
358 +
359 +it('should return false', () => {
360 +assert(!picomatch('(!(abc))', {}, true).state.negatedExtglob);
361 +assert(!picomatch('**!(abc)', {}, true).state.negatedExtglob);
362 +});
363 +});
364 +});
350 365 });