Skip to content

Commit 150484e

Browse files
committed
Fix the list outdenting visual glitch
1 parent 9c82adb commit 150484e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/spans/AztecListSpan.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,23 @@ abstract class AztecListSpan(override var nestingLevel: Int,
3838
val listText = text.subSequence(spanStart, spanEnd) as Spanned
3939

4040
if (end - spanStart - 1 >= 0 && end - spanStart <= listText.length) {
41-
val hasSublist = listText.getSpans(end - spanStart - 1, end - spanStart, AztecListSpan::class.java)
42-
.any { it.nestingLevel > nestingLevel }
43-
if (hasSublist) {
41+
// When outdenting an empty list item, a nested list span may begin at the
42+
// exact start of this line due to span boundary updates. That should not
43+
// suppress the indicator for the current line. Ignore sublists whose start
44+
// coincides with the current line start.
45+
val potentialSublists = listText.getSpans(end - spanStart - 1, end - spanStart, AztecListSpan::class.java)
46+
val hasBlockingSublist = potentialSublists.any { sub ->
47+
if (sub.nestingLevel <= nestingLevel) return@any false
48+
val subStart = listText.getSpanStart(sub)
49+
val lineStart = (listText.subSequence(0, end - spanStart) as Spanned)
50+
.lastIndexOf('\n') + 1
51+
// Only treat as blocking if the nested list actually starts after the line start
52+
// (i.e., the next line belongs to a deeper list). If it starts exactly at the
53+
// line start, we are at the first character of that nested block, which should
54+
// still show the current line indicator.
55+
subStart > lineStart
56+
}
57+
if (hasBlockingSublist) {
4458
return null
4559
}
4660
}

0 commit comments

Comments
 (0)