Skip to content

Make sure the selection in the plain text editor is inside the text bounds #2959

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

Merged
merged 3 commits into from
May 31, 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
1 change: 1 addition & 0 deletions changelog.d/2959.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crash when restoring the selection values in the plain text editor.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ fun MarkdownTextInput(
tag = TestTags.plainTextEditor.value // Needed for UI tests
setPadding(0)
setBackgroundColor(Color.TRANSPARENT)
setText(state.text.value())
val text = state.text.value()
setText(text)
inputType = InputType.TYPE_CLASS_TEXT or
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES or
InputType.TYPE_TEXT_FLAG_MULTI_LINE or
InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
if (canUpdateState) {
setSelection(state.selection.first, state.selection.last)
val textRange = 0..text.length
setSelection(state.selection.first.coerceIn(textRange), state.selection.last.coerceIn(textRange))
setOnFocusChangeListener { _, hasFocus ->
state.hasFocus = hasFocus
}
Expand Down
Loading