Skip to content

Commit

Permalink
Merge pull request #1056 from wordpress-mobile/issue/guard-against-mi…
Browse files Browse the repository at this point in the history
…ssing-history-file

Fix crash when history cache file is missing
  • Loading branch information
nbradbury authored Aug 4, 2023
2 parents 0dfd4bb + bd82705 commit 448622c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -946,10 +946,15 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
val list = LinkedList<String>()

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

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

customState.getByteArray(RETAINED_INITIAL_HTML_PARSED_SHA256_KEY)?.let {
Expand Down

0 comments on commit 448622c

Please sign in to comment.