Skip to content

Commit

Permalink
Fix TextEdit crashing on Android (#7203)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwbobo2021 committed Dec 27, 2024
1 parent e27d0ca commit e12ecb5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/renderers/skia/textlayout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ pub fn cursor_rect(
);
}

// This is needed in case of the cursor is moving to the end of the text (#7203).
let cursor_pos = cursor_pos.min(string.len());
// Not doing this check may cause crashing with non-ASCII text.
if !string.is_char_boundary(cursor_pos) {
return Default::default();
}

// SkParagraph::getRectsForRange() does not report the text box of a trailing newline
// correctly. Use the last line's metrics to get the correct coordinates (#3590).
if cursor_pos == string.len()
Expand Down

0 comments on commit e12ecb5

Please sign in to comment.