In a Nutshell

If you move a card in the learning queue into or out of a filtered deck (including by rebuilding or deleting the deck), then Anki will set all learning cards to new status and re-learning cards back to review status.

While not quite a fix, you can avoid trouble by using a small addon I wrote called filterSafety. It will prevent learning cards from being added to or removed from a filtered deck.

Background

This feature of filtered decks is right there in the manual, but like the Spanish Inquisition, no one expects it. Without warning, Anki goes about converting learning cards when you move them in and out of a filtered deck. When users figure out what’s happening, it’s a rude surprise.

In the current implementation, if you empty or delete a filtered deck while cards are still in learning, they will be turned back into new cards. In the case of failed reviews in relearning, any remaining relearning steps will be skipped.

Root of the problem

The problem is that a filtered deck can have its own learning steps. This means that there can be a mismatch between which step a learning card is on when in its original deck, and the steps in a filtered deck. You might have 3 short steps of 10, 20, and 30 minutes in the original deck, but in the filtered deck, you might have steps of 100, 200, and 300 minutes. Should a learning card on step 3 remain on step 3 when you move it to a filtered deck? That would give it an interval 10 times larger!

So clearly, there’s a bit of a problem here. The solution was to just convert learning cards back to new, and re-learning cards back to review.

What could have been done, is to at least convert learning cards back to their previous learning state. That would require that you keep track of their previous state, and Anki wasn’t programmed to do that.

I’d imagine that most people would prefer that their learning cards get the new learning steps as they’re moved around, rather than turning into new cards again.

Possible solution

It would be possible to hijack the code that moves cards into and out of temporary decks with an addon. The new code could check the revlog table to figure out which learning step the card is on, and edit the Left field for the card accordingly (it holds the step number and the total number of learning steps). This would allow learning cards to remain in the learning queue.

I found this out from someone else who had the time to look through Anki’s not-so-well commented code and figure this out. I hadn’t been annoyed enough to put in the time to do that. It also probably would have taken me longer since I’m not that great at coding.

A simple work-around

Instead of a fix for the problem, I created a much simpler work-around. We basically avoid the problem entirely by preventing cards in the learning queue from being either moved into or out of a filtered deck. This lets us rebuild filtered decks. Learning cards stay in and new cards just get added to them.

It’s a simple solution, but it’s good enough for me.

filterSafety