Skip to content

java.lang.IndexOutOfBoundsException: setSpan() #848

Open

Description

@yangshibai

When set aztec.visualEditor.filters = arrayOf(InputFilter.LengthFilter(1000)) ,it menas EditText MaxLength is 1000,next I paste piece of text with more than 500 words, the
first time is all right ,but the second time I continue paste this text ,the application crashed。

This is the crash Log:

java.lang.IndexOutOfBoundsException: setSpan (1272 ... 1272) ends beyond length 1000
at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1309)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:680)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:672)
at android.text.Selection.setSelection(Selection.java:76)
at android.text.Selection.setSelection(Selection.java:87)
at android.widget.EditText.setSelection(EditText.java:127)
at org.wordpress.aztec.AztecText.fromHtml(AztecText.kt:1158)
at org.wordpress.aztec.AztecText.paste(AztecText.kt:1598)
at org.wordpress.aztec.AztecText.paste$default(AztecText.kt:1557)
at org.wordpress.aztec.AztecText.onTextContextMenuItem(AztecText.kt:1493)
at android.widget.Editor$ActionPopupWindow.onClick(Editor.java:4327)
at android.view.View.performClick(View.java:6266)
at android.widget.TouchPanelLayout.resetChildState(TouchPanelLayout.java:58)
at android.widget.TouchPanelLayout.dispatchTouchEvent(TouchPanelLayout.java:46)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2963)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2963)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
at android.widget.PopupWindow$PopupDecorView.dispatchTouchEvent(PopupWindow.java:2397)
at android.view.View.dispatchPointerEvent(View.java:11975)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4836)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4647)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4183)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4236)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4202)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4329)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4210)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4386)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4183)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4236)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4202)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4210)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4183)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6743)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6717)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6678)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6849)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:249)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:6698)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)

Finally I found this method in AztecText class : consumeCursorPosition() calculate is wrong

Activity

  1. Riya1295 commented on Nov 26, 2020

    @Riya1295

    Any update or any solution for this issue?

  2. Bibazavr commented on Nov 19, 2024

    @Bibazavr

    Hello!

    I'm facing same error and sure that problem happened there

    Because lib setting cursor while ignoring all filters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions