Skip to content

Commit 496872d

Browse files
committed
Fix the predicate matching
1 parent 70d3332 commit 496872d

File tree

1 file changed

+6
-5
lines changed
  • wordpress-shortcodes/src/main/java/org/wordpress/aztec/plugins/shortcodes/extensions

1 file changed

+6
-5
lines changed

wordpress-shortcodes/src/main/java/org/wordpress/aztec/plugins/shortcodes/extensions/CaptionExtensions.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ fun AztecText.removeImageCaption(attributePredicate: AztecText.AttributePredicat
4545

4646
fun AztecText.hasImageCaption(attributePredicate: AztecText.AttributePredicate): Boolean {
4747
this.text.getSpans(0, this.text.length, AztecImageSpan::class.java)
48-
.firstOrNull {
49-
val wrapper = SpanWrapper<AztecImageSpan>(text, it)
50-
return text.getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan::class.java)
51-
.map { span -> span as CaptionShortcodeSpan }
52-
.any { span -> attributePredicate.matches(span.attributes) }
48+
.firstOrNull {
49+
attributePredicate.matches(it.attributes)
50+
}
51+
?.let {
52+
val wrapper = SpanWrapper(text, it)
53+
return text.getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan::class.java).isNotEmpty()
5354
}
5455

5556
return false

0 commit comments

Comments
 (0)