File tree Expand file tree Collapse file tree 3 files changed +31
-9
lines changed
main/kotlin/org/wordpress/aztec
test/kotlin/org/wordpress/aztec Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,7 @@ class AztecParser {
180180 val spanEnd = spanned.getSpanEnd(it)
181181
182182 // block spans include a newline at the end, we need to account for that
183- val newlineExpected = if (it is AztecBlockSpan ) spanEnd - 1 else spanEnd
183+ val newlineExpected = if (it is AztecBlockSpan && spanEnd > 0 ) spanEnd - 1 else spanEnd
184184
185185 if (spanEnd == spanned.length) {
186186 // no visual newline if at text end
Original file line number Diff line number Diff line change @@ -21,14 +21,14 @@ class TextDeleter private constructor(aztecText: AztecText) : TextWatcher {
2121 return
2222 }
2323
24- aztecTextRef.get()?. text?. let { text ->
25- text.getSpans( 0 , text.length, MarkForDeletion :: class .java).forEach {
26- val start = text.getSpanStart (it)
27- val end = text.getSpanEnd(it)
28-
29- if (start > - 1 && end > - 1 ) {
30- text.delete(text.getSpanStart(it), text.getSpanEnd(it) )
31- }
24+ text.getSpans( 0 , text.length, MarkForDeletion :: class .java).forEach {
25+ val start = text.getSpanStart(it)
26+ val end = text.getSpanEnd (it)
27+
28+ if (start > - 1 && end > - 1 ) {
29+ aztecTextRef.get()?.disableTextChangedListener()
30+ text.delete(start, end )
31+ aztecTextRef.get()?.enableTextChangedListener()
3232 }
3333 }
3434 }
Original file line number Diff line number Diff line change @@ -92,4 +92,26 @@ class BlockElementsTest {
9292 Assert .assertTrue(safeEmpty(editText))
9393 Assert .assertEquals(" " , editText.toHtml())
9494 }
95+
96+ @Test
97+ @Throws(Exception ::class )
98+ fun testCollapsingEmptyQuoteAboveNewline () {
99+ safeAppend(editText, " \n " )
100+ editText.setSelection(0 )
101+ editText.toggleFormatting(TextFormat .FORMAT_QUOTE )
102+ editText.text.insert(0 ," \n " )
103+
104+ Assert .assertEquals(" <br>" , editText.toHtml())
105+ }
106+
107+ @Test
108+ @Throws(Exception ::class )
109+ fun testCollapsingEmptyListAboveNewline () {
110+ safeAppend(editText, " \n " )
111+ editText.setSelection(0 )
112+ editText.toggleFormatting(TextFormat .FORMAT_ORDERED_LIST )
113+ editText.text.insert(0 ," \n " )
114+
115+ Assert .assertEquals(" <br>" , editText.toHtml())
116+ }
95117}
You can’t perform that action at this time.
0 commit comments