Exception when pressed backspace after selecting all

Exception when pressed backspace for removing characters after selected all in TMP Inputfield.
6530933--737636--upload_2020-11-17_15-47-16.png > 6530933--737633--upload_2020-11-17_15-46-57.png
Like pictures you can see white space then cause exception.
It seems that caretPositionInternal is not equal to length of text.

This happened to both versions 3.0.1 and 3.0.3.

ArgumentOutOfRangeException: Index and count must refer to a location within the string.
Parameter name: count
System.String.Remove (System.Int32 startIndex, System.Int32 count) (at <fb001e01371b4adca20013e0ac763896>:0)
TMPro.TMP_InputField.Backspace () (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMP_InputField.cs:2931)
TMPro.TMP_InputField.KeyPressed (UnityEngine.Event evt) (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMP_InputField.cs:1898)
TMPro.TMP_InputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMP_InputField.cs:2135)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.1.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:99)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2020.1.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2020.1.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)
1 Like

What are the steps to reproduce this behavior?

What specific text are you first typing in the input field?

1 Like

Here are steps to reproduce.

  1. Type β€œdddd” in input field (whatever few characters as alphabet)
  2. End your input.(focus out input field)
  3. Select again input field then selected all texts.
  4. Type β€œγ…‡β€ in input field (γ…‡ is korean not O, whatever one character as composition string(ex Korean))
  5. Press backspace keyboard button for removing.
  6. Exception will happen.
1 Like

I am not able to reproduce the issue so not sure what I am missing from the sequence above.

I am using the Korean IME (on Windows) and the β€œγ…‡β€ is on the D key. Are you using the same key to enter this β€œγ…‡β€ character?

Are you on Windows or Mac?

P.S. Since it is almost 2:00 am for me, I’ll check back in tomorrow and keep trying to reproduce this issue.

1 Like

I’m on windows.
And it’s right that β€œγ…‡β€ is on the D.
also, rich text option was enabled.
6531389--737717--reproduce.gif
I inserted gif image to show reproduce.

Thanks for checking.

P.S I found no exception occurred when Allow rich text editing option was enabled. seems to relate with these options.

1 Like

I am not able to reproduce the error using the key but I am able to reproduce the issue with the key.

Issue does not occur with Enable Rich Text Editing enabled.

Can you confirm the issue is when using and not or do you get the issue with both?

P.S. I am using Unity 2020.1.13f1 with TMP version 3.0.3.

P.S.S. I’ll get to work on fixing the issue.

As matter of fact, I got the issue when using not on windows with Unity 2020.1.8f1.
But on mac, exception when using on Unity 2020.1.13f1 with TMP version 3.0.3…
May be It’s problem with different keyboard type or different carat position.(case of me, carat was end position.)

Thanks for working on fixing.

Since I made some changes to IME handling which landed in Unity 2020.1.9f1, can you check if you still get the issue in 2020.1.9f1?

No exeption in Unity 2020.1.9f1 as you said.
I can still see white space but works well.
Thank you.