Skip to content

fix: populate single-segment scan tokens - #230

Open
JunaidAhamed-7777 wants to merge 1 commit into
micromatch:masterfrom
JunaidAhamed-7777:fix/scan-final-token
Open

JunaidAhamed-7777 wants to merge 1 commit into
micromatch:masterfrom
JunaidAhamed-7777:fix/scan-final-token

Conversation

@JunaidAhamed-7777

Copy link
Copy Markdown

When scan() receives { tokens: true }, a single-segment pattern such as *.js or ** currently returns an empty token with depth zero. The same finalization gap affects a segment immediately after ./ or a leading slash. This makes ** report maxDepth: 0 instead of Infinity.

Finalize the last token using the computed segment start, while checking that a terminal token exists. Add regressions for ordinary and negated segments, globstars, prefixes, leading slashes, empty inputs, trailing separators, and escaped terminal slashes. Default scanning and matching are unchanged.

Validation:

  • npm test: ESLint passed; 2,004 tests passed.
  • npm run test:ci: 2,004 tests passed with coverage.
  • Compared default and parts-only results across 9,331 generated patterns; no differences or new token-mode exceptions.

Human review follows draft submission.

@JunaidAhamed-7777
JunaidAhamed-7777 marked this pull request as ready for review October 13, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant