about summary refs log tree commit diff
path: root/src/actions
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/shift.rs4
-rw-r--r--src/actions/update.rs14
2 files changed, 9 insertions, 9 deletions
diff --git a/src/actions/shift.rs b/src/actions/shift.rs
index 437fcb4..6880c20 100644
--- a/src/actions/shift.rs
+++ b/src/actions/shift.rs
@@ -32,7 +32,7 @@ pub fn shift(command_options: ActionOptions, path: &str, new_cursor: usize) -> R
                 working_file.rewind()?;
                 working_file.set_len(0)?;
 
-                working_file.write_all(new_content.as_bytes())?;
+                working_file.write_all(&new_content)?;
             }
 
             file_history.write_to_file(&mut history_file)?;
@@ -47,7 +47,7 @@ pub fn shift(command_options: ActionOptions, path: &str, new_cursor: usize) -> R
                 let mut new_working_file = deleted.create_working_file(&locations)?;
                 let new_content = file_history.get_content();
 
-                new_working_file.write_all(new_content.as_bytes())?;
+                new_working_file.write_all(&new_content)?;
             }
         }
         FileState::Untracked(_) => panic!("File is not tracked with Ka."),
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));