Skip to content

Commit 448622c

Browse files
authored
Merge pull request #1056 from wordpress-mobile/issue/guard-against-missing-history-file
Fix crash when history cache file is missing
2 parents 0dfd4bb + bd82705 commit 448622c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,10 +946,15 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
946946
val list = LinkedList<String>()
947947

948948
list += array
949+
val historyCursor = customState.getInt(HISTORY_CURSOR_KEY)
950+
val inputLast = InstanceStateUtils.readAndPurgeTempInstance(INPUT_LAST_KEY, "", savedState.state)
951+
// if cursor does not match the number of history entries, it means the temp file with history has been deleted
952+
if (historyCursor == list.size) {
953+
history.historyList = list
954+
history.historyCursor = historyCursor
955+
history.inputLast = inputLast
956+
}
949957

950-
history.historyList = list
951-
history.historyCursor = customState.getInt(HISTORY_CURSOR_KEY)
952-
history.inputLast = InstanceStateUtils.readAndPurgeTempInstance<String>(INPUT_LAST_KEY, "", savedState.state)
953958
visibility = customState.getInt(VISIBILITY_KEY)
954959

955960
customState.getByteArray(RETAINED_INITIAL_HTML_PARSED_SHA256_KEY)?.let {

0 commit comments

Comments
 (0)