Make sure the selection in the plain text editor is inside the text bounds (#2959)
* Make sure the selection in the plain text editor is inside the text bounds * Add changelog
This commit is contained in:
parent
7bdf48d81d
commit
9ce7009045
2 changed files with 5 additions and 2 deletions
1
changelog.d/2959.bugfix
Normal file
1
changelog.d/2959.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Fix crash when restoring the selection values in the plain text editor.
|
||||||
|
|
@ -90,13 +90,15 @@ fun MarkdownTextInput(
|
||||||
tag = TestTags.plainTextEditor.value // Needed for UI tests
|
tag = TestTags.plainTextEditor.value // Needed for UI tests
|
||||||
setPadding(0)
|
setPadding(0)
|
||||||
setBackgroundColor(Color.TRANSPARENT)
|
setBackgroundColor(Color.TRANSPARENT)
|
||||||
setText(state.text.value())
|
val text = state.text.value()
|
||||||
|
setText(text)
|
||||||
inputType = InputType.TYPE_CLASS_TEXT or
|
inputType = InputType.TYPE_CLASS_TEXT or
|
||||||
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES or
|
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES or
|
||||||
InputType.TYPE_TEXT_FLAG_MULTI_LINE or
|
InputType.TYPE_TEXT_FLAG_MULTI_LINE or
|
||||||
InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
|
InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
|
||||||
if (canUpdateState) {
|
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 ->
|
setOnFocusChangeListener { _, hasFocus ->
|
||||||
state.hasFocus = hasFocus
|
state.hasFocus = hasFocus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue