Fix notetype original_stock_kind using wrong enum (#4382)

Use OriginalStockKind instead of StockKind when setting
original_stock_kind for basic notetype variants. The two enums
have different numeric values, causing 'Restore to Default' to
restore the wrong template.

For example, StockKind::BasicTyping has value 3, but when read
back as OriginalStockKind, value 3 corresponds to
BasicOptionalReversed instead of BasicTyping (which is 4).

This fixes the off-by-one behavior where:
- Basic (type in the answer) → Basic (optional reversed card)
- Basic (and reversed card) → Basic (optional reversed card)
- Basic (optional reversed card) → Basic (and reversed card)

Fixes #4353
This commit is contained in:
Arold0 2025-10-09 00:50:50 +02:00 committed by GitHub
parent d11b74fd38
commit 76d3237139
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -122,7 +122,7 @@ pub(crate) fn basic(tr: &I18n) -> Notetype {
pub(crate) fn basic_typing(tr: &I18n) -> Notetype { pub(crate) fn basic_typing(tr: &I18n) -> Notetype {
let mut nt = basic(tr); let mut nt = basic(tr);
nt.config.original_stock_kind = StockKind::BasicTyping as i32; nt.config.original_stock_kind = OriginalStockKind::BasicTyping as i32;
nt.name = tr.notetypes_basic_type_answer_name().into(); nt.name = tr.notetypes_basic_type_answer_name().into();
let front = tr.notetypes_front_field(); let front = tr.notetypes_front_field();
let back = tr.notetypes_back_field(); let back = tr.notetypes_back_field();
@ -138,7 +138,7 @@ pub(crate) fn basic_typing(tr: &I18n) -> Notetype {
pub(crate) fn basic_forward_reverse(tr: &I18n) -> Notetype { pub(crate) fn basic_forward_reverse(tr: &I18n) -> Notetype {
let mut nt = basic(tr); let mut nt = basic(tr);
nt.config.original_stock_kind = StockKind::BasicAndReversed as i32; nt.config.original_stock_kind = OriginalStockKind::BasicAndReversed as i32;
nt.name = tr.notetypes_basic_reversed_name().into(); nt.name = tr.notetypes_basic_reversed_name().into();
let front = tr.notetypes_front_field(); let front = tr.notetypes_front_field();
let back = tr.notetypes_back_field(); let back = tr.notetypes_back_field();
@ -156,7 +156,7 @@ pub(crate) fn basic_forward_reverse(tr: &I18n) -> Notetype {
pub(crate) fn basic_optional_reverse(tr: &I18n) -> Notetype { pub(crate) fn basic_optional_reverse(tr: &I18n) -> Notetype {
let mut nt = basic_forward_reverse(tr); let mut nt = basic_forward_reverse(tr);
nt.config.original_stock_kind = StockKind::BasicOptionalReversed as i32; nt.config.original_stock_kind = OriginalStockKind::BasicOptionalReversed as i32;
nt.name = tr.notetypes_basic_optional_reversed_name().into(); nt.name = tr.notetypes_basic_optional_reversed_name().into();
let addrev = tr.notetypes_add_reverse_field(); let addrev = tr.notetypes_add_reverse_field();
nt.add_field(addrev.as_ref()); nt.add_field(addrev.as_ref());