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 SkiaParagraph.getLineForVerticalPosition #1012

Merged
merged 1 commit into from Jan 24, 2024

Conversation

m-sasha
Copy link

@m-sasha m-sasha commented Jan 23, 2024

SkiaParagraph.getLineForVerticalPosition currently returns 0 when given a position beyond the last line. This is counter to its documentation:

Returns line number closest to the given graphical vertical position.
If you ask for a vertical position before 0, you get 0; if you ask for a vertical position
beyond the last line, you get the last line.

Proposed Changes

  • Reimplement SkiaParagraph.getLineForVerticalPosition using binary search
  • Make it correctly return the last line when given a large input.

Testing

Test: Added a unit test

Issues Fixed

Fixes: JetBrains/compose-multiplatform#4058

…rch, and make it correctly return the last line when given a large input.
@m-sasha m-sasha merged commit ee14b93 into jb-main Jan 24, 2024
6 checks passed
@m-sasha m-sasha deleted the m-sasha/fix-getLineForVerticalPosition branch January 24, 2024 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants