From 4f954112b8c8cf266a8338cc86166f912c2da88c Mon Sep 17 00:00:00 2001 From: Mel Date: Tue, 21 Sep 2021 22:43:20 +0200 Subject: Byte differ --- src/actions/update.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/actions/update.rs') diff --git a/src/actions/update.rs b/src/actions/update.rs index 73a9222..aa9c3a4 100644 --- a/src/actions/update.rs +++ b/src/actions/update.rs @@ -5,7 +5,7 @@ use anyhow::{Context, Result}; use crate::{ files::{Locations, FileState}, history::{FileChange, FileHistory}, - text_diff::TextChange, + diff::ContentChange, }; use super::ActionOptions; @@ -40,10 +40,10 @@ fn update_file(file_state: FileState, locations: &Locations) -> Result<()> { FileState::Untracked(untracked) => { let mut file = untracked.load_file()?; - let mut file_content = String::new(); - file.read_to_string(&mut file_content)?; + let mut file_content = Vec::new(); + file.read_to_end(&mut file_content)?; - let change = FileChange::Updated(vec![TextChange::Inserted { + let change = FileChange::Updated(vec![ContentChange::Inserted { at: 0, new_content: file_content, }]); @@ -59,12 +59,12 @@ fn update_file(file_state: FileState, locations: &Locations) -> Result<()> { let file_history = FileHistory::from_file(&mut history_file)?; - let mut new_content = String::new(); - working_file.read_to_string(&mut new_content)?; + let mut new_content = Vec::new(); + working_file.read_to_end(&mut new_content)?; let old_content = file_history.get_content(); - let changes = TextChange::diff(&old_content, &new_content); + let changes = ContentChange::diff(&old_content, &new_content); let mut new_history = file_history; new_history.add_change(FileChange::Updated(changes)); -- cgit 1.4.1