File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
main/kotlin/org/wordpress/aztec/handlers
test/kotlin/org/wordpress/aztec Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,13 @@ class HeadingHandler : BlockHandler<AztecHeadingSpan>(AztecHeadingSpan::class.ja
4444 }
4545
4646 override fun handleEndOfBufferMarker () {
47- // adjust the block end to only include the chars before the end-of-text marker. A newline will be there.
47+ if (block.start == markerIndex) {
48+ // ok, this list item has the marker as its first char so, nothing more to do here.
49+ return
50+ }
51+
52+ // the heading has bled over to the marker so, let's adjust its range to just before the marker.
53+ // There's a newline there hopefully :)
4854 block.end = markerIndex
4955 }
5056
Original file line number Diff line number Diff line change @@ -234,4 +234,17 @@ class HeadingTest() {
234234 editText.text.delete(mark - 1 , mark)
235235 Assert .assertEquals(" <h1 foo=\" bar\" >Heading 1unstyled</h1>" , editText.toHtml())
236236 }
237+
238+ @Test
239+ @Throws(Exception ::class )
240+ fun deleteHeadingChars_Issue287 () {
241+ editText.fromHtml(" <h1>he</h1>" )
242+
243+ var l = safeLength(editText)
244+ editText.text.delete(l - 1 , l)
245+
246+ l = safeLength(editText)
247+ editText.text.delete(l - 1 , l)
248+ Assert .assertEquals(" <h1></h1>" , editText.toHtml())
249+ }
237250}
You can’t perform that action at this time.
0 commit comments