From b7650c22dbb42a7eeb55d148610c893a74280369 Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 10 Oct 2021 21:35:18 +0200 Subject: Check if file changed on Update. --- src/actions/update.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src') 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( 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) + } } } } -- cgit 1.4.1