Skip to content

Commit bc8eaa0

Browse files
committed
fix: only clear span when Spanned.SPAN_COMPOSING is not set
See: #178
1 parent 77dde10 commit bc8eaa0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • app/src/main/kotlin/org/fossify/notes/extensions

app/src/main/kotlin/org/fossify/notes/extensions/EditText.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ import org.fossify.commons.views.MyEditText
66

77
fun MyEditText.enforcePlainText() {
88
val stripSpans = InputFilter { source, start, end, _, _, _ ->
9-
val sub = source.subSequence(start, end)
10-
if (sub is Spanned) sub.toString() else sub
9+
if (source !is Spanned) return@InputFilter null
10+
val hasRealStyle = source.getSpans(start, end, Any::class.java)
11+
.any { span ->
12+
(source.getSpanFlags(span) and Spanned.SPAN_COMPOSING) == 0
13+
}
14+
15+
if (hasRealStyle) source.subSequence(start, end).toString() else null
1116
}
1217
filters = (filters ?: emptyArray()) + stripSpans
1318
}

0 commit comments

Comments
 (0)