Skip to content

fix: normalize token IDs regardless of alphabetize setting - #735

Merged
drwpow merged 2 commits into
terrazzoapp:mainfrom
impsislegobatman:fix/consistent-token-ids-without-alphabetize
Apr 24, 2026
Merged

drwpow merged 2 commits into
terrazzoapp:mainfrom
impsislegobatman:fix/consistent-token-ids-without-alphabetize

Conversation

@impsislegobatman

Copy link
Copy Markdown
Contributor

Summary

Fixes #734

When alphabetize is set to false, the early return in process.ts (line 258) skipped the refToTokenID() conversion, causing token IDs to remain in JSON Pointer format (#/size/sm) instead of dot notation (size.sm).

This change ensures refToTokenID() always runs on token IDs while only conditionally sorting them, so token ID format is consistent regardless of the alphabetize setting.

Changes

  • Removed the early return when alphabetize === false
  • Always apply refToTokenID() conversion to normalize token IDs
  • Conditionally sort with alphaComparator only when alphabetize !== false
  • Conditionally sort group token arrays only when alphabetize !== false

Test plan

  • All 258 existing tests pass
  • Verified build succeeds

When `alphabetize` was set to `false`, the early return on line 258
skipped the `refToTokenID()` conversion, causing token IDs to remain
in JSON Pointer format (#/size/sm) instead of dot notation (size.sm).

This change ensures `refToTokenID()` always runs on token IDs while
only conditionally sorting them.

Fixes terrazzoapp#734
@changeset-bot

changeset-bot Bot commented Apr 16, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f99db0c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

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

Adds two test cases:
- Verifies token IDs use dot notation when alphabetize is false
  (the bug from terrazzoapp#734 - IDs were using JSON Pointer format)
- Verifies token IDs use dot notation and are sorted when
  alphabetize is true

@drwpow drwpow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thank you! We should release this.

@drwpow
drwpow merged commit 827c43d into terrazzoapp:main Apr 24, 2026
4 checks passed
@drwpow drwpow mentioned this pull request Apr 24, 2026
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.

Parsed token IDs differ depending on alphabetize option

2 participants