From 76d3237139b3e73b98f5a5b4dfeeeea2f0554644 Mon Sep 17 00:00:00 2001 From: Arold0 <165577303+arold0@users.noreply.github.com> Date: Thu, 9 Oct 2025 00:50:50 +0200 Subject: [PATCH] Fix notetype original_stock_kind using wrong enum (#4382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- CONTRIBUTORS | 2 +- rslib/src/notetype/stock.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a18833b04..cc651e198 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -249,7 +249,7 @@ Toby Penner Danilo Spillebeen Matbe766 Amanda Sternberg -arold0 +arold0 ******************** diff --git a/rslib/src/notetype/stock.rs b/rslib/src/notetype/stock.rs index 9b5df66d5..b27881809 100644 --- a/rslib/src/notetype/stock.rs +++ b/rslib/src/notetype/stock.rs @@ -122,7 +122,7 @@ pub(crate) fn basic(tr: &I18n) -> Notetype { pub(crate) fn basic_typing(tr: &I18n) -> Notetype { 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(); let front = tr.notetypes_front_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 { 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(); let front = tr.notetypes_front_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 { 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(); let addrev = tr.notetypes_add_reverse_field(); nt.add_field(addrev.as_ref());