File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
AnkiDroid/src/main/java/com/ichi2/anki Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1325,6 +1325,8 @@ class NoteEditorFragment :
13251325
13261326 // treat add new note and edit existing note independently
13271327 if (addNote) {
1328+ // truncate the fields to the actual size the notetype supports
1329+ editorNote!! .fields = editorNote!! .fields.take(editorNote!! .notetype.fields.length()).toMutableList()
13281330 // load all of the fields into the note
13291331 for (f in editFields!! ) {
13301332 updateField(f)
@@ -2492,7 +2494,17 @@ class NoteEditorFragment :
24922494 if (note == null || addNote) {
24932495 getColUnsafe.run {
24942496 val notetype = notetypes.current()
2495- Note .fromNotetypeId(this @run, notetype.id)
2497+ val newNote = Note .fromNotetypeId(this @run, notetype.id)
2498+ editorNote?.let {
2499+ if (editorNote!! .fields.size > newNote.fields.size) {
2500+ newNote.fields = editorNote!! .fields.toMutableList()
2501+ } else {
2502+ editorNote!! .fields.forEachIndexed { i, field ->
2503+ newNote.fields[i] = field
2504+ }
2505+ }
2506+ }
2507+ newNote
24962508 }
24972509 } else {
24982510 note
@@ -2891,7 +2903,9 @@ class NoteEditorFragment :
28912903 if (! getColUnsafe.config.getBool(ConfigKey .Bool .ADDING_DEFAULTS_TO_CURRENT_DECK )) {
28922904 deckId = getColUnsafe.defaultsForAdding().deckId
28932905 }
2894-
2906+ for (f in editFields!! ) {
2907+ updateField(f)
2908+ }
28952909 refreshNoteData(FieldChangeType .changeFieldCount(shouldReplaceNewlines()))
28962910 setDuplicateFieldStyles()
28972911 }
You can’t perform that action at this time.
0 commit comments