Skip to content

Commit 25a55b6

Browse files
fix: revert Felipe's changes that introduced bugs caught by tests
1 parent 4fb183b commit 25a55b6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle, private val h
174174

175175
if (spanEnd > start) {
176176
// ensure css style is applied
177-
spanToApply.applyInlineStyleAttributes(editableText, start, end)
177+
(precedingSpan as IAztecInlineSpan).applyInlineStyleAttributes(editableText, start, end)
178178
return // we are adding text inside span - no need to do anything special
179179
} else {
180-
applySpan(spanToApply, spanStart, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
180+
applySpan(precedingSpan as IAztecInlineSpan, spanStart, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
181181
}
182182
}
183183
}
@@ -193,7 +193,8 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle, private val h
193193

194194
if (followingSpan != null) {
195195
val spanEnd = editableText.getSpanEnd(followingSpan)
196-
applySpan(spanToApply, start, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
196+
applySpan(followingSpan as IAztecInlineSpan, start, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
197+
editableText.setSpan(followingSpan, start, spanEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
197198
}
198199
}
199200

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class AztecToolbarTest {
602602
Assert.assertFalse(italicButton.isChecked)
603603

604604
italicButton.performClick()
605-
Assert.assertEquals("<b>bol</b><b><em>ditalic</em></b>", editText.toHtml())
605+
Assert.assertEquals("<b>bol</b><b><i>ditalic</i></b>", editText.toHtml())
606606
}
607607

608608
/**

0 commit comments

Comments
 (0)