Skip to content

Commit 9b1b4c8

Browse files
authored
fix: styles merging logic (#281)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect --> # Summary - Fixes: #279 ## Test Plan - Make one word bold. - Make another, separate word bold. - Create a selection starting from the middle of the first bold word to the middle of the second bold word (the selection will include bold → regular → bold segments). - Call toggleBold. - Notice that styles are properly applied ## Screenshots / Videos https://github.com/user-attachments/assets/06a4a0f2-be03-467a-a982-f4413a86e1c7 ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ❌ | | Android | ✅ |
1 parent 5c634fd commit 9b1b4c8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.swmansion.enriched.styles
22

33
import android.text.Editable
44
import android.text.Spannable
5+
import android.util.Log
56
import com.swmansion.enriched.EnrichedTextInputView
67
import com.swmansion.enriched.spans.EnrichedSpans
78
import com.swmansion.enriched.utils.getSafeSpanBoundaries
@@ -54,8 +55,7 @@ class InlineStyles(private val view: EnrichedTextInputView) {
5455
val spanEnd = spannable.getSpanEnd(span)
5556
var finalStart: Int? = null
5657
var finalEnd: Int? = null
57-
58-
spannable.removeSpan(span)
58+
if (spanStart == -1 || spanEnd == -1) continue
5959

6060
if (start == spanStart && end == spanEnd) {
6161
setSpanOnFinish = false

0 commit comments

Comments
 (0)