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

fix(text): fix substract with overflow panic #217

Merged
merged 1 commit into from
Jan 21, 2024

Conversation

Valentin271
Copy link
Contributor

Fixes #197

This change avoids the panic, visually the behavior is the same.
However I'm not sure this is correct, because it means sometimes it won't be subtracted (and we get a wrong index?).


I don't get why we would need to subtract one to the index of the glyph under the cursor only if the cursor is associated with the previous frame. Also removing this if Affinity::Before altogether doesn't seem to change anything ...
Have I misunderstood something in my reasoning?

Copy link
Collaborator

@CosmicHorrorDev CosmicHorrorDev left a comment

Choose a reason for hiding this comment

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

I believe this is the correct behavior. The affinity stuff is used to determine which run the cursor should be a part of when it's between two text runs. Subtracting one (kinda shaky logic that it's exactly one) ensures that the cursor falls on the previous text run when between two, and the only value that saturates would be zero which should only happen when you're already on the first text run

@CosmicHorrorDev CosmicHorrorDev merged commit 5bca55d into Inlyne-Project:main Jan 21, 2024
7 checks passed
@Valentin271 Valentin271 deleted the fix/text-panic branch January 21, 2024 18:39
@Valentin271
Copy link
Contributor Author

Ok I think I'm misinterpreting what a text run is. With your explanation it seems more like a chunk of text (and now it makes sense to be between two elements, selecting the previous glyph) whereas I understood it as kind of a render of the document.

@CosmicHorrorDev CosmicHorrorDev added C-bug Category: Something isn't working A-font Area: Dealing with font loading/rendering C-unreleased-regression Category: A regression that hasn't been released yet labels Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-font Area: Dealing with font loading/rendering C-bug Category: Something isn't working C-unreleased-regression Category: A regression that hasn't been released yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

thread main panicked at src/text.rs:206:17 attempt to subtract with overflow
2 participants