diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt b/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt index cb6fd3407..62ca1070f 100644 --- a/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt +++ b/aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt @@ -946,10 +946,15 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown val list = LinkedList() 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(INPUT_LAST_KEY, "", savedState.state) visibility = customState.getInt(VISIBILITY_KEY) customState.getByteArray(RETAINED_INITIAL_HTML_PARSED_SHA256_KEY)?.let {