aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2021-10-10 21:35:18 +0200
committerMel <einebeere@gmail.com>2021-10-10 21:35:18 +0200
commitb7650c22dbb42a7eeb55d148610c893a74280369 (patch)
tree1a0517f8bbca7dc7ed3a1c1988833d107f64d92c
parente619e85ae4ce3765030728eb3190ce7605b58d43 (diff)
downloadka-b7650c22dbb42a7eeb55d148610c893a74280369.tar.zst
ka-b7650c22dbb42a7eeb55d148610c893a74280369.zip
Check if file changed on Update.
-rw-r--r--src/actions/update.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/actions/update.rs b/src/actions/update.rs
index a4a64b3..05379c1 100644
--- a/src/actions/update.rs
+++ b/src/actions/update.rs
@@ -97,15 +97,17 @@ fn get_new_history_for_file<FS: Fs>(
let changes = ContentChange::diff(&old_content, &new_content);
- // TODO: Check if file was changed.
-
- let mut new_history = file_history;
- new_history.add_change(FileChange {
- change_index: cursor + 1,
- variant: FileChangeVariant::Updated(changes),
- });
-
- Ok(Some((history_file, new_history)))
+ if !changes.is_empty() {
+ let mut new_history = file_history;
+ new_history.add_change(FileChange {
+ change_index: cursor + 1,
+ variant: FileChangeVariant::Updated(changes),
+ });
+
+ Ok(Some((history_file, new_history)))
+ } else {
+ Ok(None)
+ }
}
}
}