On Mon, 9 Nov 2026 08:27:11 GMT, Robert Lichtenberger <[email protected]> 
wrote:

> This patch provides a minimal solution to JDK-8393470 [TextInputControl] 
> double click on leading char selects wrong word.
> It simply checks if the caret is already at the start of a word and in that 
> case it prevents the jumping to the start of the previous word.
> 
> It takes the one scenario from testDoubleClickSelectsCharacterClassBlocks 
> that is fixed by the patch and moves it into a separate test method.
> 
> The other scenarios from testDoubleClickSelectsCharacterClassBlocks are 
> removed, since they cannot be achieved without changing a lot of behavior and 
> the current behavior while not being _my_ favorite way can be argued as 
> "correct" in the absence of a formal specification.
> 
> 
> ---------
> - [X] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Question: Should we still keep the failign scenarios in a new disabled test?
We can write a small javadoc comment that those might be behavior we may aim to 
have at one point -- or not. No formal specification as you wrote. 

But if someone checks the code in 5 years, this may will help to document, that 
we were indeed aware of this.

modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java
 line 420:

> 418:         if (pos == 0) {
> 419:             atWordStart = true;
> 420:         } else if (pos < textArea.getLength() ){

Suggestion:

        } else if (pos < textArea.getLength()) {

modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java
 line 422:

> 420:         } else if (pos < textArea.getLength() ){
> 421:             String text = textArea.getText();
> 422:             atWordStart = Character.isWhitespace(text.charAt(pos-1)) && 
> !Character.isWhitespace(text.charAt(pos));

Suggestion:

            atWordStart = Character.isWhitespace(text.charAt(pos - 1)) && 
!Character.isWhitespace(text.charAt(pos));

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

PR Review: https://git.openjdk.org/jfx/pull/2363#pullrequestreview-5826649664
PR Review Comment: https://git.openjdk.org/jfx/pull/2363#discussion_r4513340307
PR Review Comment: https://git.openjdk.org/jfx/pull/2363#discussion_r4513338655

Reply via email to