mirror of
https://github.com/ankitects/anki.git
synced 2025-12-11 05:46:55 -05:00
change detection needs to ignore collection mtime bump
This commit is contained in:
parent
42d5d8071d
commit
b448afdc57
1 changed files with 14 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ pub(crate) use changes::UndoableChange;
|
|||
|
||||
pub use crate::ops::Op;
|
||||
use crate::{
|
||||
collection::undo::UndoableCollectionChange,
|
||||
ops::{OpChanges, StateChanges},
|
||||
prelude::*,
|
||||
};
|
||||
|
|
@ -22,6 +23,18 @@ pub(crate) struct UndoableOp {
|
|||
pub changes: Vec<UndoableChange>,
|
||||
}
|
||||
|
||||
impl UndoableOp {
|
||||
/// True if changes empty, or only the collection mtime has changed.
|
||||
fn has_changes(&self) -> bool {
|
||||
!matches!(
|
||||
&self.changes[..],
|
||||
&[] | &[UndoableChange::Collection(
|
||||
UndoableCollectionChange::Modified(_)
|
||||
)]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum UndoMode {
|
||||
NormalOp,
|
||||
|
|
@ -82,7 +95,7 @@ impl UndoManager {
|
|||
|
||||
fn end_step(&mut self) {
|
||||
if let Some(step) = self.current_step.take() {
|
||||
if !step.changes.is_empty() {
|
||||
if step.has_changes() {
|
||||
if self.mode == UndoMode::Undoing {
|
||||
self.redo_steps.push(step);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue