flexmark-java icon indicating copy to clipboard operation
flexmark-java copied to clipboard

Clarification about BasedSequence#endOffset

Open saket opened this issue 3 years ago • 1 comments

Hello, I'm trying to understand why does BasedSequence#endOffset is always 1 more than its index value. For example, this code prints 4 instead of the 3 I expected by assuming that offsets are 0-based.

val parser = Parser.builder().build()
val node = parser.parse("*hi*")
println(node.endOffset)

What might I be missing?

saket avatar Aug 01 '22 04:08 saket

Apparently this is inline with how styling works on most platforms where the end offset is assumed as "exclusive". Can I convince you to either rename endOffset to endOffsetExclusive or at least mention this in its doc?

saket avatar Aug 01 '22 05:08 saket