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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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?

if (currentText.codePointAt(currentOffset).isWhitespace() && !currentText.codePointAt(
nextOffset
).isWhitespace()
) {
return currentOffset
return nextOffset
} else {
currentOffset = nextOffset
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class CupertinoTextFieldDelegateTest {
}

@Test
@Ignore // TODO: Remove ignore https://youtrack.jetbrains.com/issue/COMPOSE-1214/
fun determineCursorDesiredOffset_tap_in_the_middle_of_the_symbols_sequence() {
val givenOffset = 34
val desiredOffset = 53
Expand All @@ -99,6 +100,7 @@ class CupertinoTextFieldDelegateTest {
}

@Test
@Ignore // TODO: Remove ignore https://youtrack.jetbrains.com/issue/COMPOSE-1214/
fun determineCursorDesiredOffset_tap_in_the_middle_of_the_whitespaces() {
val givenOffset = 48
val desiredOffset = 53
Expand All @@ -107,6 +109,7 @@ class CupertinoTextFieldDelegateTest {
}

@Test
@Ignore // TODO: Remove ignore https://youtrack.jetbrains.com/issue/COMPOSE-1214/
fun determineCursorDesiredOffset_tap_on_the_standalone_symbols_sequence() {
val givenOffset = 56
val desiredOffset = 57
Expand Down
Loading