mirror of
https://github.com/ankitects/anki.git
synced 2025-12-12 22:36: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;
|
pub use crate::ops::Op;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
collection::undo::UndoableCollectionChange,
|
||||||
ops::{OpChanges, StateChanges},
|
ops::{OpChanges, StateChanges},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
@ -22,6 +23,18 @@ pub(crate) struct UndoableOp {
|
||||||
pub changes: Vec<UndoableChange>,
|
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)]
|
#[derive(Debug, PartialEq)]
|
||||||
enum UndoMode {
|
enum UndoMode {
|
||||||
NormalOp,
|
NormalOp,
|
||||||
|
|
@ -82,7 +95,7 @@ impl UndoManager {
|
||||||
|
|
||||||
fn end_step(&mut self) {
|
fn end_step(&mut self) {
|
||||||
if let Some(step) = self.current_step.take() {
|
if let Some(step) = self.current_step.take() {
|
||||||
if !step.changes.is_empty() {
|
if step.has_changes() {
|
||||||
if self.mode == UndoMode::Undoing {
|
if self.mode == UndoMode::Undoing {
|
||||||
self.redo_steps.push(step);
|
self.redo_steps.push(step);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue