Repository navigation
fix: accept integer-pixel scroll distances containing 0 in the JSON schema - #1343
Merged
lujjjh merged 1 commit intoAug 9, 2026
Merged
Conversation
lujjjh
reviewed
Aug 9, 2026
…chema The JSON-schema pattern for Scheme.Scrolling.Distance.Pixel used the character class [1-9], which excludes 0. This made the schema reject valid integer-pixel scroll distances containing a 0 (10px, 20px, 100px, 1000px) while the Swift decoder (^([\d.]+)(px|)$ in Distance.swift) accepted them — the schema was stricter than the parser. Replace it with ^(?:0|[1-9]\d*)(?:\.\d+)?px$, which keeps the original intent of rejecting leading zeros (01px, 007px) that the reversed digit classes had lost, and anchors the end of the value so a trailing suffix (10pxfoo) is rejected as the Swift decoder already does. Regenerate Configuration.json from the type. Co-authored-by: Claude <[email protected]>
YuriNachos
force-pushed
the
YuriNachos/w3-linearmouse-schema
branch
from
August 9, 2026 00:56
b2b5dd1 to
d03f6f4
Compare
Contributor
Author
|
Applied your suggestion — you are right on both counts, and it is a better fix than mine. Pushed as I checked all three patterns against a corpus before taking it:
Two things my version missed:
One deliberate difference worth flagging: on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The JSON-schema pattern for
Scheme.Scrolling.Distance.Pixelrejected valid integer-pixel scroll distances that contain the digit0(e.g.10px,20px,100px,1000px), even though the Swift runtime decoder accepts them. This made the schema stricter than the actual configuration parser, so valid configs failed schema validation / editor checks.Root Cause
Documentation/Configuration.d.tsdeclared the Pixel pattern as^\d[1-9]*(\.\d+)?px. The character class[1-9]excludes0, so any multi-digit integer containing a0fails to match: for10px,\dconsumes1and[1-9]*cannot consume the0, leaving0pxunmatched against the trailingpx. The Swift decoder (Distance.swift, pattern^([\d.]+)(px|)$) accepts these values, so the schema was a stricter-than-runtime typo (intended[0-9]).Changes
Documentation/Configuration.d.ts: Pixel@patterninteger body[1-9]→[0-9](^\d[0-9]*(\.\d+)?px).Documentation/Configuration.json: regenerated from the type vianpm run generate:json-schema(pre-commit hook).Integer-pixel values (
10px,20px,100px,1000px) now validate; previously-matching values (36px,256px,3.5px) are unchanged, and non-pixel values are still rejected.Verification
swiftformat --lint .clean;swiftlint .clean.** TEST SUCCEEDED **— 523 tests, 0 failures.10px/20px/100px/1000pxnow match (failed before);36px/256px/3.5pxstill match;auto/abc/10/-5px/1.2.3px/pxrejected.