Hey all, I have this weird problem that I think m...
# compose
l
Hey all, I have this weird problem that I think might be a bug but I can't be sure. I have this
BasicTextField
that has a visual transformation applied to it that transforms
# Title
to
Title
and changes the size of the text (markdown). It constructs a
TransformedText
object with an
OffsetMapping
to account for the 2 characters that have been removed. However there seems to be a bug because when I type in
# Title
it gets transformed to
Title
in the text field however when I move the cursor using the arrow keys to the end of the line the application crashes with an out of bounds error. I traced this down and it looks like its an issue with the
isLtr()
function as it uses
selection.end
without performing a
OffsetMapping
conversion on it.
Copy code
// TextPreparedSelection.kt

    private fun isLtr(): Boolean {
        val direction = layoutResult?.getParagraphDirection(selection.end)
        return direction != ResolvedTextDirection.Rtl
    }
Any ideas on how I could resolve this issue?
👍 1
m
I would guess you have a bug in your offset mapping. I was getting similar errors when I return
offset - charactersRemoved
That caused negative values to be returned from
originalToTransformed
l
I think that the mapping is working since using home and end properly do the mapping. It just seems like the isLtr function is missing a call to perform the transformation
z
It’s very possible there's a bug here, please file and we'll look into it
l
Is there any way that I could patch it on my end (for testing) and maybe put up a PR?
z
l
Thank you for sharing that issue!