Anki/rslib/src/backend
Damien Elmes be994f4102 add support for custom undo steps, and merging multiple actions
Allows add-on authors to define their own label for a group of undoable
operations. For example:

def mark_and_bury(
    *,
    parent: QWidget,
    card_id: CardId,
) -> CollectionOp[OpChanges]:
    def op(col: Collection) -> OpChanges:
        target = col.add_custom_undo_entry("Mark and Bury")
        col.sched.bury_cards([card_id])
        card = col.get_card(card_id)
        col.tags.bulk_add(note_ids=[card.nid], tags="marked")
        return col.merge_undo_entries(target)

    return CollectionOp(parent, op)

The .add_custom_undo_entry() is for adding your own custom actions.
When extending a standard Anki action, instead store `target = 
col.undo_status().last_step` after executing the standard operation.

This started out as a bigger refactor that required a separate
.commit_undoable() call to be run after each operation, instead of
having each operation return changes directly. But that proved to be
somewhat cumbersome in unit tests, and ran the risk of unexpected
behaviour if the caller invoked an operation without remembering to
finalize it.
2021-05-06 16:39:06 +10:00
..
scheduler support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
search make it more ergonomic to search directly via nodes in Rust 2021-04-30 11:37:55 +10:00
sync update Rust deps 2021-04-27 22:18:12 +10:00
adding.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
card.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
cardrendering.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
collection.rs add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
config.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
dbproxy.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
deckconfig.rs deckconf -> deckconfig 2021-04-20 21:54:24 +10:00
decks.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
error.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
generic.rs DeckConfId -> DeckConfigId 2021-04-28 21:09:26 +10:00
i18n.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
media.rs empty/restore media trash shouldn't clear undo 2021-04-30 19:07:30 +10:00
mod.rs update Rust deps 2021-04-27 22:18:12 +10:00
notes.rs move pub functions to top of notes/mod.rs 2021-04-29 14:08:15 +10:00
notetypes.rs update GUI to allow notetype addition undo 2021-04-30 15:58:08 +10:00
ops.rs add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
progress.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
stats.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
tags.rs fix invalid outer transaction in clear_unused_tags() 2021-04-30 19:09:02 +10:00