Skip to content

Commit b6788f9

Browse files
committed
Added comment.
1 parent 3168d91 commit b6788f9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/formatting/BlockFormatter.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,14 @@ class BlockFormatter(editor: AztecText, val listStyle: ListStyle, val quoteStyle
186186
}
187187

188188
spanTypes.forEach { spanType ->
189-
val mightHaveLingeringListItem = spanType.isAssignableFrom(AztecListItemSpan::class.java)
189+
// when removing style from multiple selected lines, if the last selected line is empty
190+
// or at the end of editor the selection wont include the trailing newline/EOB marker
191+
// that will leave us with orphan <li> tag, so we need to shift index to the right
192+
val hasLingeringEmptyListItem = spanType.isAssignableFrom(AztecListItemSpan::class.java)
190193
&& editableText.length > end
191194
&& (editableText[end] == '\n' || editableText[end] == Constants.END_OF_BUFFER_MARKER)
192195

193-
val endModifier = if (mightHaveLingeringListItem) 1 else 0
196+
val endModifier = if (hasLingeringEmptyListItem) 1 else 0
194197

195198
val spans = editableText.getSpans(start, end + endModifier, spanType)
196199
spans.forEach { span ->

0 commit comments

Comments
 (0)