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

IndexOutOfBounds when hitting space bar #27

Open
josegbel opened this issue Oct 9, 2020 · 1 comment · May be fixed by #36
Open

IndexOutOfBounds when hitting space bar #27

josegbel opened this issue Oct 9, 2020 · 1 comment · May be fixed by #36

Comments

@josegbel
Copy link

josegbel commented Oct 9, 2020

Using the following mask.

val postCodeMask = Mask(
            value = "___ ___",
            character = '_',
            style = MaskStyle.NORMAL
        )

I get an IndexOutOfBoundsExeption when hitting the space character when the user hits the space bar key, not sure if this an expected behaviour. I would expect here the space bar to be treated as the space character.

Stack trace:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: __________________t, PID: 21295
    java.lang.IndexOutOfBoundsException: setSpan (5 ... 5) ends beyond length 4
        at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1325)
        at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684)
        at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676)
        at android.text.Selection.setSelection(Selection.java:94)
        at android.text.Selection.setSelection(Selection.java:78)
        at android.text.Selection.setSelection(Selection.java:153)
        at com.santalu.maskara.MaskResultKt.apply(MaskResult.kt:26)
        at com.santalu.maskara.MaskChangedListener.afterTextChanged(MaskChangedListener.kt:31)
        at android.widget.TextView.sendAfterTextChanged(TextView.java:10551)
        at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:13388)
        at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:1277)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:577)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:507)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:37)
        at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:843)
        at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:197)
        at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:177)
        at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:339)
        at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:89)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

@ashu090990
Copy link

any update... is it resolved?

@dshatz dshatz linked a pull request Sep 12, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants