On Tue, 14 Apr 2020 11:47:21 GMT, Kevin Rushforth <[email protected]> wrote:
>> Just a comment on how to add a failing test: we can replace the actual
>> typing (in the TestFx context) by
>> programmatically replacing the selection, actually, it doesn't even need the
>> skin (so no scene nor parent) because all
>> collaborators are in TextInputControl:
>> /**
>> * Test for JDK-8176270: register changeListener on selectedText,
>> select at
>> * end of text and replace selection throws.
>> */
>> @Test
>> public void addingChangeListenerNoSkin() {
>> TextField textField = new TextField();
>> textField.setText("1234 5678");
>> textField.selectedTextProperty()
>> .addListener((o, ov, nv) -> {});
>>
>> textField.positionCaret(5);
>> textField.selectEnd();
>> textField.replaceSelection("d");
>> }
>>
>> Similarly, an invalidationListener that access the selectedText throws,
>> while an invalidationListener not accessing the
>> selected is fine. ~~So it looks like a one-off when evaluating the actual
>> selection during the process, somehow it's
>> not yet ready~~ That was my wrong assumption, the culprit is really the
>> incorrect clamping of a no-longer valid end
>> index when adjusting the selectedText binding (as @Kevin noted above). It
>> shows only if the selectedText must be
>> re-evaluated before the selectionRange is updated, f.i. forced by a
>> changeListener (or direct access). To make the
>> error show up on the test thread, replace the uncaughtExceptionHandler
>> before (and cleanup after):
>> @Before public void setup() throws Exception {
>> Thread.currentThread().setUncaughtExceptionHandler((thread,
>> throwable) -> {
>> if (throwable instanceof RuntimeException) {
>> throw (RuntimeException)throwable;
>> } else {
>>
>> Thread.currentThread().getThreadGroup().uncaughtException(thread, throwable);
>> }
>> });
>> textInput = (TextInputControl) type.newInstance();
>> }
>>
>>
>> @After public void cleanup() {
>> Thread.currentThread().setUncaughtExceptionHandler(null);
>> }
>
> @koppor are you planning to resume work on this PR?
Closing, since there has been no activity for 3 months.
@koppor - if you would like to pursue this, please address the pending feedback
and reopen the PR.
-------------
PR: https://git.openjdk.java.net/jfx/pull/73