diff options
author | Dan Davison <dandavison7@gmail.com> | 2022-06-20 14:44:07 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2022-06-20 14:48:28 -0400 |
commit | 71d9d8cc05b747195a9af745af0510248c7e7a67 (patch) | |
tree | 83ed7a1a150b24c518944643fa5794df1714c2ef | |
parent | e420652adb52d4a0d8dd968e1cd2754cb0c947c1 (diff) |
Delete handle_pending_line_with_diff_namediff-header-handler-line-rewrite
-rw-r--r-- | src/delta.rs | 1 | ||||
-rw-r--r-- | src/handlers/diff_header.rs | 56 | ||||
-rw-r--r-- | src/handlers/diff_header_diff.rs | 1 |
3 files changed, 0 insertions, 58 deletions
diff --git a/src/delta.rs b/src/delta.rs index 7ba29973..7db71c7b 100644 --- a/src/delta.rs +++ b/src/delta.rs @@ -173,7 +173,6 @@ impl<'a> StateMachine<'a> { || self.emit_line_unchanged()?; } - self.handle_pending_mode_line_with_diff_name()?; self.painter.paint_buffered_minus_and_plus_lines(); self.painter.emit()?; Ok(()) diff --git a/src/handlers/diff_header.rs b/src/handlers/diff_header.rs index 3e317bee..c3da55b3 100644 --- a/src/handlers/diff_header.rs +++ b/src/handlers/diff_header.rs @@ -1,8 +1,6 @@ use std::borrow::Cow; use std::path::Path; -use unicode_segmentation::UnicodeSegmentation; - use super::draw; use crate::config::Config; use crate::delta::{DiffType, Source, State, StateMachine}; @@ -171,43 +169,6 @@ impl<'a> StateMachine<'a> { self.config, ) } - - pub fn handle_pending_mode_line_with_diff_name(&mut self) -> std::io::Result<()> { - if !self.mode_info.is_empty() { - let format_label = |label: &str| { - if !label.is_empty() { - format!("{} ", label) - } else { - "".to_string() - } - }; - let format_file = |file| match ( - self.config.hyperlinks, - utils::path::absolute_path(file, self.config), - ) { - (true, Some(absolute_path)) => features::hyperlinks::format_osc8_file_hyperlink( - absolute_path, - None, - file, - self.config, - ), - _ => Cow::from(file), - }; - let label = format_label(&self.config.file_modified_label); - let name = get_repeated_file_path_from_diff_line(&self.diff_line) - .unwrap_or_else(|| "".to_string()); - let line = format!("{}{}", label, format_file(&name)); - write_generic_diff_header_header_line( - &line, - &line, - &mut self.painter, - &mut self.mode_info, - self.config, - ) - } else { - Ok(()) - } - } } /// Write `line` with DiffHeader styling. @@ -296,23 +257,6 @@ fn parse_diff_header_line(line: &str, git_diff_name: bool) -> (String, FileEvent } } -/// Given input like "diff --git a/src/my file.rs b/src/my file.rs" -/// return Some("src/my file.rs") -fn get_repeated_file_path_from_diff_line(line: &str) -> Option<String> { - if let Some(line) = line.strip_prefix("diff --git ") { - let line: Vec<&str> = line.graphemes(true).collect(); - let midpoint = line.len() / 2; - if line[midpoint] == " " { - let first_path = _parse_file_path(&line[..midpoint].join(""), true); - let second_path = _parse_file_path(&line[midpoint + 1..].join(""), true); - if first_path == second_path { - return Some(first_path); - } - } - } - None -} - fn _parse_file_path(s: &str, git_diff_name: bool) -> String { // It appears that, if the file name contains a space, git appends a tab // character in the diff metadata lines, e.g. diff --git a/src/handlers/diff_header_diff.rs b/src/handlers/diff_header_diff.rs index fdd2d39a..71367166 100644 --- a/src/handlers/diff_header_diff.rs +++ b/src/handlers/diff_header_diff.rs @@ -22,7 +22,6 @@ impl<'a> StateMachine<'a> { } else { State::DiffHeader(DiffType::Unified) }; - self.handle_pending_mode_line_with_diff_name()?; self.handled_diff_header_header_line_file_pair = None; self.diff_line = self.line.clone(); if !self.should_skip_line() { |