jasonwilliams / anki

Anki VSCode Plugin
MIT License
278 stars 32 forks source link

Check both front and back for metadata to avoid generating new CardIDs #129

Closed ccammack closed 3 months ago

ccammack commented 3 months ago

To reproduce bug #128, enable anki.md.insertNewCardID and run Anki:Send To Own Deck multiple times on this deck and note that it generates new CardIDs each time:

# Test CardID Bug

## Front (2024-06-08 19:51:42)
%
Back (2024-06-08 19:51:42)

## Front (2024-06-08 19:51:56)

%
Back (2024-06-08 19:51:56)

## Front (2024-06-08 19:52:04)
%

Back (2024-06-08 19:52:04)

## Front (2024-06-08 19:52:13)

%

Back (2024-06-08 19:52:13)

## Front (2024-06-08 19:52:20)
Back (2024-06-08 19:52:20)

## Front (2024-06-08 19:52:25)

Back (2024-06-08 19:52:25)

Apply the fix and repeat the test to see that the CardIDs are only generated once..

jasonwilliams commented 3 months ago

Thanks, I can confirm this patch works and I have tried the reproduction steps listed in the linked-issue. I've noticed this doesn't actually update the contents of the card in Anki but I think we never got around to implementing this.

looks like just linting left to sort out

ccammack commented 3 months ago

Updates seem to work for me on the test deck if anki.md.updateCards is enabled.

jasonwilliams commented 3 months ago

ah yes thanks, just tested and it works fine, I can see the bug is fixed. The CI looks unrelated so ill ignore that, it would be great if we had a test suite for this, but I won't hold up this PR on that basis

jasonwilliams commented 3 months ago

This has been released: https://github.com/jasonwilliams/anki/releases/tag/v1.3.3