fix: use char count instead of byte length for json_schema spans - #164
Open
Kubudak90 wants to merge 1 commit into
Open
fix: use char count instead of byte length for json_schema spans#164Kubudak90 wants to merge 1 commit into
Kubudak90 wants to merge 1 commit into
Conversation
The lint used (byte length) for annotation spans, but expects character offsets. This caused incorrect diagnostics and potential panics when the markdown source contained multi-byte UTF-8 characters before the code block. Fix by using instead, matching the fix already applied to in ethereum#151. Closes ethereum#100 (same root cause, different lint).
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.
Fixes #100.
The
json_schemalint was usingsource.len()(byte length) for annotation spans, which causes a panic when the source contains non-ASCII characters (e.g., Unicode in CSL-JSON citations). Theannotate-snippetscrate expects character counts, not byte lengths.Changes:
source.len()tosource.chars().count()injson_schema.rsRoot cause: When a code block contains multi-byte UTF-8 characters,
source.len()returns the byte length (e.g., 99 bytes for 98 characters), but the annotation system expects character indices. This mismatch triggers the panic:All tests pass.