fix(format): drop a temperature's space before its trailing zeros #168

Merged
abiwab merged 1 commit from fix/format-temperature-zeros into main 2026-11-16 23:24:11 +01:00
Owner

Problem

The formatter removed trailing zeros (rule 4) before the space in front of ° (rule 5). Rule 4's patterns allow no space before the unit, so ^{160.0 °C} only became ^{160.0°C}, and a second run was needed to reach ^{160°C}.

Fix

  • Rule 5 now runs before rule 4: the space goes first, then the zeros. The rule numbers are kept to keep the merge into dev/1.5 small.
  • Tests in packages/format/tests/formatter.test.ts: ^{160.0 °C} is fixed in one run (one spacing fix, one zero removed, a second run changes nothing), and ^{37.50 °C} keeps the zero that matters (^{37.5°C}).

Checks

  • bun test: 2498 pass (after bun run build from main), including the LSP formatting-parity test.
  • bun run lint, typecheck of @gram-lang/format, bun run conformance (107 cases).
  • Changeset: format-temperature-zeros.md (@gram-lang/format, patch).

Once merged, main is merged into dev/1.5 as usual. That merge conflicts in packages/format/src/index.ts (dev/1.5 rewrote rule 4 for the decimal comma and added rule 4b): keep dev/1.5's rules and move rule 5 above rule 4. The test file conflict is two blocks appended at the end: keep both.

## Problem The formatter removed trailing zeros (rule 4) before the space in front of `°` (rule 5). Rule 4's patterns allow no space before the unit, so `^{160.0 °C}` only became `^{160.0°C}`, and a second run was needed to reach `^{160°C}`. ## Fix - Rule 5 now runs before rule 4: the space goes first, then the zeros. The rule numbers are kept to keep the merge into `dev/1.5` small. - Tests in `packages/format/tests/formatter.test.ts`: `^{160.0 °C}` is fixed in one run (one spacing fix, one zero removed, a second run changes nothing), and `^{37.50 °C}` keeps the zero that matters (`^{37.5°C}`). ## Checks - `bun test`: 2498 pass (after `bun run build` from `main`), including the LSP formatting-parity test. - `bun run lint`, typecheck of `@gram-lang/format`, `bun run conformance` (107 cases). - Changeset: `format-temperature-zeros.md` (`@gram-lang/format`, patch). Once merged, `main` is merged into `dev/1.5` as usual. That merge conflicts in `packages/format/src/index.ts` (`dev/1.5` rewrote rule 4 for the decimal comma and added rule 4b): keep `dev/1.5`'s rules and move rule 5 above rule 4. The test file conflict is two blocks appended at the end: keep both.
fix(format): drop a temperature's space before its trailing zeros
All checks were successful
CI / Build & Test (pull_request) Successful in 3m39s
268c8ea7c8
abiwab scheduled this pull request to auto merge when all checks succeed 2026-11-16 23:22:04 +01:00
abiwab merged commit 4fbcb4d03b into main 2026-11-16 23:24:11 +01:00
abiwab deleted branch fix/format-temperature-zeros 2026-11-16 23:24:11 +01:00
Sign in to join this conversation.
No description provided.