RFR: 8330462: StringIndexOutOfBoundException when typing anything into TextField [v23]
Oliver Kopp
duke at openjdk.org
Thu Apr 25 22:37:44 UTC 2024
On Thu, 25 Apr 2024 21:41:14 GMT, Oliver Kopp <duke at openjdk.org> wrote:
>> Fixes https://bugs.openjdk.org/browse/JDK-8330462.
>>
>> If the parameter `maxLength` is larger than `Integer.MAX_VALUE - start`, then an addition of `start` to it leads to a negative value. This is "fixed" by using `Math.max` comparing the `maxLength` and `maxLength + start`.
>
> Oliver Kopp has updated the pull request incrementally with one additional commit since the last revision:
>
> Make use of Utils.clamp function
(I switched to TextField; is a bit easier for me to debug)
Intermedidate testing result:
When pressing "space", the rectangle moves correctly. When moving the cursor "inside" these much spaces, it also moves.

---
Ctrl+A leads to the box borders be of length of the complete text, not the visible text

---
I thought, following would help, but does not:
*/
public void selectRange(int anchor, int caretPosition) {
caretPosition = Utils.clamp(0, caretPosition, getLength());
anchor = Utils.clamp(0, anchor, getLength());
+ notifyAccessibleAttributeChanged(AccessibleAttribute.SELECTION_START);
+ notifyAccessibleAttributeChanged(AccessibleAttribute.SELECTION_END);
+ notifyAccessibleAttributeChanged(AccessibleAttribute.CARET_OFFSET);
+
TextFormatter.Change change = new TextFormatter.Change(this, getFormatterAccessor(), anchor, caretPosition);
TextFormatter<
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1442#issuecomment-2078282435
More information about the openjfx-dev
mailing list