Skip to content

Commit c68f291

Browse files
authored
fix: only clear span when Spanned.SPAN_COMPOSING is not set (#181)
* fix: only clear span when `Spanned.SPAN_COMPOSING` is not set See: #178 * docs: update changelog
1 parent 77dde10 commit c68f291

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Fixed broken input when typing with certain keyboards ([#178])
11+
912
## [1.3.0] - 2025-07-12
1013
### Changed
1114
- Updated translations
@@ -55,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5558
[#99]: https://github.com/FossifyOrg/Notes/issues/99
5659
[#110]: https://github.com/FossifyOrg/Notes/issues/110
5760
[#164]: https://github.com/FossifyOrg/Notes/issues/164
61+
[#178]: https://github.com/FossifyOrg/Notes/issues/178
5862

5963
[Unreleased]: https://github.com/FossifyOrg/Notes/compare/v1.3.0...HEAD
6064
[1.3.0]: https://github.com/FossifyOrg/Notes/compare/v1.2.0...v1.3.0

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)