Skip to content

Commit a30168b

Browse files
committed
Merge branch 'develop' into issue/289-multiple-headings
2 parents 6c7e8ac + c8bbee9 commit a30168b

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/handlers/HeadingHandler.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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

aztec/src/test/kotlin/org/wordpress/aztec/HeadingTest.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ class HeadingTest() {
235235
Assert.assertEquals("<h1 foo=\"bar\">Heading 1unstyled</h1>", editText.toHtml())
236236
}
237237

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+
}
250+
238251
@Test
239252
@Throws(Exception::class)
240253
fun addHeading_issue289() {
@@ -249,5 +262,4 @@ class HeadingTest() {
249262
safeAppend(editText, "Heading 2")
250263
Assert.assertEquals("<h1>Heading 1</h1><h2>Heading 2</h2>", editText.toHtml())
251264
}
252-
253-
}
265+
}

0 commit comments

Comments
 (0)