0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

fix: moving to note type with fewer sticky fields

IndexOutOfBoundsException when moving from
'Basic (optional reversed card)' to 'Basic (and reversed card)'
after setting 'Toggle Sticky' for all fields

This is due to 'toggle sticky' being present, but the field not
existing

Fixes 13719

Quick fix to stop a crash. Needs more thought and testing
This commit is contained in:
David Allison 2023-04-26 22:53:09 +01:00 committed by Mike Hardy
parent 2ecaf6079a
commit a0fe79cbae

View File

@ -1432,9 +1432,15 @@ class NoteEditor : AnkiActivity(), DeckSelectionListener, SubtitleListener, Tags
} }
} }
@NeedsTest("13719: moving from a note type with more fields to one with fewer fields")
private fun saveToggleStickyMap() { private fun saveToggleStickyMap() {
for ((key) in mToggleStickyText) { for ((key) in mToggleStickyText) {
mToggleStickyText[key] = mEditFields!![key]!!.fieldText // handle fields for different note type with different size
if (key < mEditFields!!.size) {
mToggleStickyText[key] = mEditFields!![key]?.fieldText
} else {
mToggleStickyText.remove(key)
}
} }
} }