On Fri, 7 Feb 2020 18:12:23 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> This is a WIP PR. Requesting for comments.
>> 
>> I could not replicate the test given at 
>> https://bugs.openjdk.java.net/browse/JDK-8176270 without TestFX. I 
>> nevertheless let my try to replicate the @Test things in here.
>> 
>> The fix is just a wild guess without really understanding the side effects 
>> of `.addListener`.
> 
> modules/javafx.controls/src/main/java/javafx/scene/control/TextInputControl.java
>  line 170:
> 
>> 169:                 // In case the start is after the whole txt, nothing 
>> valid is selected. Thus, return the default.
>> 170:                 if (start >= length) return "";
>> 171:                 return txt.substring(start, end);
> 
> This change seems OK, and might be clearer than the existing code, but the 
> existing code is correct, and produces the same effect.

yeah, it is correct - but while we are changing the impl, we might go the whole 
way and clean up :) my pref would be to add the check for start to the 
short-circuit at the beginning of the method, something like

        String txt = text.get();
        IndexRange sel = selection.get();
        if (txt == null || sel == null || sel.getStart() >= text.getLength()) 
return "";

-------------

PR: https://git.openjdk.java.net/jfx/pull/73

Reply via email to