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

Fixed crash in Cupertino Textfield when a last symbol is a carriage return symbol #1229

Merged
merged 5 commits into from
Apr 4, 2024

Conversation

mazunin-v-jb
Copy link

@mazunin-v-jb mazunin-v-jb commented Mar 29, 2024

Proposed Changes

  • Fixed crash in cupertino textfield after tapping at the end of penultimate line when last line consists of carriage return symbol only
  • Fixed check for tap on the right edge of penultimate line when last line consists of carriage return symbol only

Testing

Test: Open the app, go Components -> Textfields -> AlmostFullScreen, scroll to the bottom, tap at the end of the 99 line.

Issues Fixed

Fixes: https://youtrack.jetbrains.com/issue/COMPOSE-1207/iOS-crash-in-TextField
Should also fix JetBrains/compose-multiplatform#4531

Google CLA

You need to sign the Google Contributor’s License Agreement at https://cla.developers.google.com/.
This is needed since we synchronise most of the code with Google’s AOSP repository. Signing this agreement allows us to synchronise code from your Pull Requests as well.

…imate line when last line consists of carriage return symbol only
@mazunin-v-jb mazunin-v-jb self-assigned this Mar 29, 2024
@mazunin-v-jb mazunin-v-jb marked this pull request as draft March 29, 2024 20:49
…imate line + fixed logic by tap on the right edge of the penultimate end when last line consists of any whitespace symbol only
@mazunin-v-jb mazunin-v-jb marked this pull request as ready for review April 2, 2024 02:27
@mazunin-v-jb mazunin-v-jb force-pushed the v.mazunin/cupertino-textfield-crash-fix branch from 90ddf68 to 7d9ca66 Compare April 2, 2024 09:59
@@ -123,12 +123,12 @@ internal fun findNextNonWhitespaceSymbolsSubsequenceStartOffset(

nextOffset = charIterator.next()

while (nextOffset != BreakIterator.DONE) {
while (nextOffset < currentText.length) { // charIterator.next() works one more time than needed, better use this
Copy link
Collaborator

@ASalavei ASalavei Apr 2, 2024

Choose a reason for hiding this comment

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

Can we use if (nextOffset != BreakIterator.DONE) on the line 124 to make code a bit more elegant and get rid of the comment in current line?

@mazunin-v-jb mazunin-v-jb merged commit ae6461d into jb-main Apr 4, 2024
6 checks passed
@mazunin-v-jb mazunin-v-jb deleted the v.mazunin/cupertino-textfield-crash-fix branch April 4, 2024 12:56
igordmn pushed a commit that referenced this pull request Apr 4, 2024
…eturn symbol (#1229)

## Proposed Changes

- Fixed crash in cupertino textfield after tapping at the end of
penultimate line when last line consists of carriage return symbol only
- Fixed check for tap on the right edge of penultimate line when last
line consists of carriage return symbol only


## Testing

Test: Open the app, go Components -> Textfields -> AlmostFullScreen,
scroll to the bottom, tap at the end of the 99 line.

## Issues Fixed

Fixes:
https://youtrack.jetbrains.com/issue/COMPOSE-1207/iOS-crash-in-TextField
Should also fix
JetBrains/compose-multiplatform#4531

## Google CLA
You need to sign the Google Contributor’s License Agreement at
https://cla.developers.google.com/.
This is needed since we synchronise most of the code with Google’s AOSP
repository. Signing this agreement allows us to synchronise code from
your Pull Requests as well.
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.

findNextNonWhitespaceSymbolsSubsequenceStartOffset crash
3 participants