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:51:02 -0400 |
commit | 8fdd0b4450438ecc5df9e8e8d20987ff65c549ca (patch) | |
tree | d42fd8158eaead61256dcf57be903cf0032934b6 | |
parent | e420652adb52d4a0d8dd968e1cd2754cb0c947c1 (diff) |
Delete handle_pending_line_with_diff_namediff-header-handlers-rewrite
-rw-r--r-- | src/delta.rs | 1 | ||||
-rw-r--r-- | src/handlers/diff_header.rs | 38 | ||||
-rw-r--r-- | src/handlers/diff_header_diff.rs | 1 |
3 files changed, 1 insertions, 39 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..cec55ed2 100644 --- a/src/handlers/diff_header.rs +++ b/src/handlers/diff_header.rs @@ -171,43 +171,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. @@ -298,6 +261,7 @@ 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") +#[allow(unused)] 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(); 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() { |