Skip to content

caret and anchor stale after selectRange with listeners #874

@Groostav

Description

@Groostav

If you attempt to use selectRange to update caret and anchor positions that have attached listeners, the caret and anchor potitions will be stale.

@Test fun `sscce`(){
    val underTest = StyleClassedTextArea()

    //comment out this line of code and the test passes
    val dontCare = Bindings.createStringBinding(Callable { "binded" }, underTest.caretPositionProperty(), underTest.anchorProperty())
    underTest.appendText("asdf")
    
    //act
    underTest.selectRange(1, 2)

    //assert
    assertThat(underTest.selectedText).isEqualTo("s") //OK
    assertThat(listOf(underTest.anchor, underTest.caretPosition)).isEqualTo(listOf(1, 2)) //fail
    //actual: 0, 2
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions