fix: detect empty cards when template uses special field conditionals#4807
Open
marcusl07 wants to merge 3 commits into
Open
fix: detect empty cards when template uses special field conditionals#4807marcusl07 wants to merge 3 commits into
marcusl07 wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue (required)
Fixes #4750
Summary / motivation (required)
new_cards_required_normal()builds a set of non-empty fields from the note's actual fields, but only special-casesTags. Other special fields likeDeck,Subdeck,Card,CardFlag,Type, andCardIDare always populated at render time but were missing from this set. This caused{{^Deck}}conditionals to be incorrectly evaluated as potentially rendering, making cards appear non-empty to the checker. The fix adds all always-present special fields tononempty_fields.Steps to reproduce (required)
{{^Deck}}{{Back}}{{/Deck}}How to test (required)
Run
./ninja check:pytest— a new regression testtest_empty_cards_special_fieldsinpylib/tests/test_cards.pycovers this case.Checklist (minimum)
./ninja checkor an equivalent relevant check locally.Details
New test verifies that a card with
{{^Deck}}{{Back}}{{/Deck}}as its front template is correctly detected as empty.Before / after behavior (optional)
Before: cards using special field conditionals like
{{^Deck}}were not detected as empty. After: they are correctly flagged.Risk / compatibility / migration (optional)
Low risk. Only affects empty card detection logic, not card rendering or scheduling.
UI evidence (required for visual changes; otherwise N/A)
N/A
Scope