11package org.wordpress.aztec.handlers
22
33import android.text.Spannable
4- import org.wordpress.aztec.Constants
54import org.wordpress.aztec.spans.AztecHeadingSpan
65import org.wordpress.aztec.watchers.TextDeleter
76
@@ -27,26 +26,13 @@ class HeadingHandler : BlockHandler<AztecHeadingSpan>(AztecHeadingSpan::class.ja
2726 TextDeleter .mark(text, newlineIndex, newlineIndex + 1 )
2827 }
2928
30- // fun handleNewlineAtTextEnd()
31- // got a newline while being at the end-of-text. We'll let the current list item engulf it and will wait
32- // for the end-of-text marker event in order to attach the new list item to it when that happens.
29+ override fun handleNewlineAtTextEnd () {
30+ block.end = newlineIndex + 1
31+ }
3332
3433 override fun handleNewlineInBody () {
35-
36- // if the new newline is the second-last character of the block and the last one is a newline (which
37- // is a visual newline) or the end-of-buffer marker, or it's the last character of the text then it's the last
38- // actual character of the block
39- val atEndOfBlock = (newlineIndex == block.end - 2 &&
40- (text[block.end - 1 ] == Constants .NEWLINE || text[block.end - 1 ] == Constants .END_OF_BUFFER_MARKER )) ||
41- newlineIndex == text.length - 1
42-
43- if (atEndOfBlock) {
44- // newline added at the end of the block (right before its visual newline) so, just end the block and
45- // not add a new block after it
46- } else {
47- // newline added at some position inside the block. Let's split the block into two
48- cloneHeading(text, block.span, newlineIndex + 1 , block.end)
49- }
34+ // newline added at some position inside the block. Let's split the block into two
35+ cloneHeading(text, block.span, newlineIndex + 1 , block.end)
5036
5137 block.end = newlineIndex + 1
5238 }
0 commit comments