Skip to content

Commit d306eb8

Browse files
committed
Check the history cursor against number of history entries.
1 parent f29186e commit d306eb8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,10 +946,18 @@ 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+
// if cursor does not match the number of history entries, it means the temp file with history has been deleted
951+
if (historyCursor == list.size) {
952+
history.historyList = list
953+
history.historyCursor = historyCursor
954+
history.inputLast = InstanceStateUtils.readAndPurgeTempInstance<String>(
955+
INPUT_LAST_KEY,
956+
"",
957+
savedState.state
958+
)
959+
}
949960

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

955963
customState.getByteArray(RETAINED_INITIAL_HTML_PARSED_SHA256_KEY)?.let {

0 commit comments

Comments
 (0)