Skip to content
Source
Sign inSign up
TanStack/highlight

test: preserve independent tokenizer contexts #47

Mergedtannerlinsleymerged 1 commit intomain fromtaren/highlight-context-lifetimesmerged by tannerlinsley

tannerlinsleycommented

Add four regression cases for independent tokenizer contexts across calls. A tokenizer can use context or method identity when selecting ranges, and it can replace a method for its current invocation. Reusing those values between calls changes the resulting highlighting.

The cases cover context identity, tokenize identity, hasLanguage identity, and a method mutation that must not leak to the next invocation. A depth-pooled prototype passed the broad compatibility corpus but failed all four targeted cases on Node and Bun; that prototype was rejected.

Validation: all 12 local gates pass, including 371 tests. All 214 compiled implementation/declaration files are byte-identical to published v1.2.3. This changes tests only, with an empty changeset and no package implementation, API, dependency or performance change.

Summary by CodeRabbit

  • Tests
    • Added coverage verifying that separate highlighting calls receive independent tokenizer contexts. The tests also check that context changes made during one call do not carry over to the next.
    1. 🦋 Changeset detected

      Latest commit: bde1770754456bbf7f42e9397944c05f4e62165b

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 0 packages

      When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      • Source mode: Auto
      • Repository: Unavailable
      • Branch: Unavailable
      • File: No configuration file from this repository applied
      • Commit: Unavailable
      • Layers: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: d3f6f692-2f16-460d-a2b5-c6bf60aa5c50
      Commits

      Reviewing files that changed from the base of the PR and between aecee665235f68cfb6cfe67953bc9036b04a41ae and bde1770754456bbf7f42e9397944c05f4e62165b.

      Files selected for processing: 2
      • .changeset/context-lifetime-coverage.md
      • test/core.test.ts

      Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

      Walkthrough

      The pull request adds a test that checks tokenizer context independence across highlight calls. It also adds a changeset file with an empty package map and no description.

      Changes: Tokenizer context lifetime coverage

      Layer / File(s)Summary
      Context independence regression test
      test/core.test.ts, .changeset/context-lifetime-coverage.md
      The test checks fresh context objects and methods across two highlight calls, including isolation from mutation of hasLanguage. Each call is expected to produce a keyword token for x. The changeset file has an empty package map and no description.

      Estimated code review effort: 2 (Simple) | ~5 minutes

      Change: Other

      Merge Risk: Minimal · up to bde17

      No actionable merge-blocking risk remains.

      Pre-merge checks: Passed 5
      Check nameStatusExplanation
      Title checkPassedThe title "test: preserve independent tokenizer contexts" matches the main change. The PR adds four regression tests that check tokenizer context, tokenize, and hasLanguage identity, and a method muta…
      Description checkPassedThe description states the purpose of the change: four regression cases for independent tokenizer contexts across calls. It lists the cases covered, reports the rejected depth-pooled prototype, and gi…
      Docstring CoveragePassedNo eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Title check

      Explanation

      The title "test: preserve independent tokenizer contexts" matches the main change. The PR adds four regression tests that check tokenizer context, tokenize, and hasLanguage identity, and a method mutation that must not leak across calls. The PR changes tests only. The title uses a conventional prefix, is short, and names the behavior under test.

      Full details: Description check

      Explanation

      The description states the purpose of the change: four regression cases for independent tokenizer contexts across calls. It lists the cases covered, reports the rejected depth-pooled prototype, and gives validation results (12 local gates, 371 tests, 214 byte-identical files versus v1.2.3). It also states that the change has no package implementation, API, dependency, or performance impact. The repository template has two sections, Changes and Validation. The description has no headings. Its content maps to both sections, but the Validation content does not include focused fixtures or a size/benchmark result, which the template asks for. The description does not follow the template structure.

      Full details: Docstring Coverage

      Explanation

      No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)

      Finishing Touches
      Generate docstrings
      • Commit to this branch
      • Create a new PR
      Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      Share
    3. tannerlinsley merged this8d061b1

    4. tannerlinsley closed this

Sign in to join this conversation.