On Sun, 9 Feb 2020 14:40:25 GMT, Jeanette Winzenburg <faste...@openjdk.org> wrote:
>> I left comments inline. This will need changes. Also, you will need to >> provide a test that fails without the fix and >> passes with the fix. > > 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? ------------- PR: https://git.openjdk.java.net/jfx/pull/73