SadConsole icon indicating copy to clipboard operation
SadConsole copied to clipboard

Small issue with TextBox and Caret

Open coldwarrl opened this issue 3 years ago • 0 comments

In TextBox.cs

protected void ValidateCursorPosition() { if (MaxLength != 0 && EditingText.Length == MaxLength) { if (_caretPos > EditingText.Length) _caretPos = EditingText.Length - 1; } ... }

if (_caretPos > EditingText.Length) should be if (_caretPos >= EditingText.Length)

else the caret moves right, exceeding MaxLength when typing stuff in the textbox. I tested it, should work fine with the proposed fix :). @Thraka can also do a PR if you like

coldwarrl avatar Jul 10 '22 17:07 coldwarrl

@coldwarrl Actually, I think the behavior is correct and that code should be deleted 😁 If the code runs (with your modification, which I think is what is was supposed to do originally) the caret is placed on the last character. If you press backspace, you delete the character behind it, not the last character.

Thraka avatar Sep 11 '22 18:09 Thraka