anki/rslib/src
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
..
backend add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
card deckconf -> deckconfig 2021-04-20 21:54:24 +10:00
collection add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
config add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
deckconfig confirm deletion is requiring a full sync 2021-04-28 22:21:16 +10:00
decks DeckConfId -> DeckConfigId 2021-04-28 21:09:26 +10:00
error tidy up Rust imports 2021-04-18 18:38:54 +10:00
media remove some unneeded transactions from tests 2021-04-30 19:18:02 +10:00
notes add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
notetype support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
revlog tidy up Rust imports 2021-04-18 18:38:54 +10:00
scheduler add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
search support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
stats tidy up Rust imports 2021-04-18 18:38:54 +10:00
storage update backend to support undoing of notetype changes 2021-04-30 12:54:59 +10:00
sync update backend to support undoing of notetype changes 2021-04-30 12:54:59 +10:00
tags tidy up Rust imports 2021-04-18 18:38:54 +10:00
undo add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
adding.rs switch NoteType to Notetype 2021-03-27 22:03:19 +10:00
backend_proto.rs NF: add AGPL licence missing in some file 2021-01-31 21:50:21 +01:00
browser_table.rs remove some imports duplicated by prelude 2021-04-19 18:22:43 +10:00
cloze.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
dbcheck.rs update backend to support undoing of notetype changes 2021-04-30 12:54:59 +10:00
findreplace.rs update backend to support undoing of notetype changes 2021-04-30 12:54:59 +10:00
i18n.rs drop the legacy enum from rslib, and pass separate module/message idx 2021-03-27 11:56:31 +10:00
latex.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
lib.rs deckconf -> deckconfig 2021-04-20 21:54:24 +10:00
log.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
markdown.rs render deck description with markdown; strip images 2021-02-06 15:02:40 +10:00
ops.rs add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
preferences.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
prelude.rs support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
serde.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
template_filters.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
template.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
text.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
timestamp.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
types.rs update scheduling ops 2021-04-06 16:38:42 +10:00
version.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00