summaryrefslogtreecommitdiffstats
path: root/src/delta.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/delta.rs')
-rw-r--r--src/delta.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/delta.rs b/src/delta.rs
index 81202bf8..e8f3938d 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -64,7 +64,7 @@ struct StateMachine<'a> {
plus_file: String,
minus_file_event: parse::FileEvent,
plus_file_event: parse::FileEvent,
- file_paths_from_diff_line: (Option<String>, Option<String>),
+ diff_line: String,
painter: Painter<'a>,
config: &'a Config,
@@ -95,7 +95,7 @@ impl<'a> StateMachine<'a> {
plus_file: "".to_string(),
minus_file_event: parse::FileEvent::NoEvent,
plus_file_event: parse::FileEvent::NoEvent,
- file_paths_from_diff_line: (None, None),
+ diff_line: "".to_string(),
current_file_pair: None,
handled_file_meta_header_line_file_pair: None,
painter: Painter::new(writer, config),
@@ -259,7 +259,7 @@ impl<'a> StateMachine<'a> {
self.painter.paint_buffered_minus_and_plus_lines();
self.state = State::FileMeta;
self.handled_file_meta_header_line_file_pair = None;
- self.file_paths_from_diff_line = parse::get_file_paths_from_diff_line(&self.line);
+ self.diff_line = self.line.clone();
Ok(false)
}
@@ -278,9 +278,10 @@ impl<'a> StateMachine<'a> {
// In the case of ModeChange only, the file path is taken from the diff
// --git line (since that is the only place the file path occurs);
// otherwise it is taken from the --- / +++ line.
- self.minus_file = match (&file_event, &self.file_paths_from_diff_line) {
- (parse::FileEvent::ModeChange(_), (Some(file), _)) => file.clone(),
- _ => path_or_mode,
+ self.minus_file = if let parse::FileEvent::ModeChange(_) = &file_event {
+ parse::get_repeated_file_path_from_diff_line(&self.diff_line).unwrap_or(path_or_mode)
+ } else {
+ path_or_mode
};
self.minus_file_event = file_event;
@@ -325,9 +326,10 @@ impl<'a> StateMachine<'a> {
// In the case of ModeChange only, the file path is taken from the diff
// --git line (since that is the only place the file path occurs);
// otherwise it is taken from the --- / +++ line.
- self.plus_file = match (&file_event, &self.file_paths_from_diff_line) {
- (parse::FileEvent::ModeChange(_), (_, Some(file))) => file.clone(),
- _ => path_or_mode,
+ self.plus_file = if let parse::FileEvent::ModeChange(_) = &file_event {
+ parse::get_repeated_file_path_from_diff_line(&self.diff_line).unwrap_or(path_or_mode)
+ } else {
+ path_or_mode
};
self.plus_file_event = file_event;
self.painter