Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert text_for_attribute length assertion comparison #211

Merged
merged 2 commits into from
Aug 4, 2024

Conversation

exvacuum
Copy link
Contributor

@exvacuum exvacuum commented Aug 4, 2024

I was trying to work with markup attributes in my project and would encounter a panic when executing the Line::text_for_attribute function, as it would consistently fail the following assertion:

assert!(
    self.text.len() <= attribute.position + attribute.length,
    "Attribute \"{attribute}\" represents a range not representable by this text: \"{}\". \
Does this MarkupAttribute belong to this MarkupParseResult?",
    self.text
);

This assertion seems to be checking that the text length is shorter than the attribute's range. This pull request just flips the comparison from <= to >=.

@janhohenheim
Copy link
Member

janhohenheim commented Aug 4, 2024

Hmm? The original code makes sense to me. If this attribute is pointing past the text, something is wrong.
Edit: whoops, after rethinking, this makes sense. Thanks!

@janhohenheim janhohenheim enabled auto-merge August 4, 2024 20:45
@janhohenheim janhohenheim merged commit 8918900 into YarnSpinnerTool:main Aug 4, 2024
4 checks passed
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.

2 participants