Skip to content

Commit 9660f62

Browse files
authored
Merge pull request #307 from wordpress-mobile/issue/306-image-crash
Issue/306 image crash
2 parents 47d205f + 6bfac7a commit 9660f62

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ class AztecText : EditText, TextWatcher, UnknownHtmlSpan.OnUnknownHtmlClickListe
223223

224224
install()
225225

226+
// Needed to properly initialize the cursor position
227+
setSelection(0)
228+
226229
enableTextChangedListener()
227230

228231
isViewInitialized = true

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ class LineBlockFormatter(editor: AztecText) : AztecFormatter(editor) {
120120
span.textView = editor
121121

122122
val spanBeforeMedia = editableText.getSpans(selectionStart, selectionEnd, AztecBlockSpan::class.java)
123-
.firstOrNull {
124-
selectionStart == editableText.getSpanEnd(it)
125-
}
123+
.firstOrNull {
124+
selectionStart == editableText.getSpanEnd(it)
125+
}
126126

127127
val spanAfterMedia = editableText.getSpans(selectionStart, selectionEnd, AztecBlockSpan::class.java)
128-
.firstOrNull {
129-
selectionStart == editableText.getSpanStart(it)
130-
}
128+
.firstOrNull {
129+
selectionStart == editableText.getSpanStart(it)
130+
}
131131

132132
val mediaStartIndex = selectionStart
133133
val mediaEndIndex = selectionStart + 1

0 commit comments

Comments
 (0)