summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-12-26 23:55:05 +0000
committerDan Davison <dandavison7@gmail.com>2020-12-26 23:55:05 +0000
commit162b98f67e6dc452a206686fee0d75d80251b7c6 (patch)
treeea113eab28c11574e4abbf323ef559c5f8732f14
parent91f1440b868571309311887d8995f6e527d00966 (diff)
Emit file in hunk header even when there is no frag
Fixes #309
-rw-r--r--src/delta.rs47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/delta.rs b/src/delta.rs
index e401e269..86508a73 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -485,33 +485,36 @@ fn handle_hunk_header_line(
if !config.color_only {
writeln!(painter.writer)?;
}
- if !line.is_empty() {
+ if !line.is_empty() || config.hunk_header_style_include_file_path {
if config.hunk_header_style_include_file_path {
let _ = write!(
&mut painter.output_buffer,
- "{}: ",
- config.file_style.paint(plus_file)
+ "{}{} ",
+ config.file_style.paint(plus_file),
+ if line.is_empty() { "" } else { ":" },
);
};
- let lines = vec![(line, State::HunkHeader)];
- let syntax_style_sections = Painter::get_syntax_style_sections_for_lines(
- &lines,
- &State::HunkHeader,
- &mut painter.highlighter,
- &painter.config,
- );
- Painter::paint_lines(
- syntax_style_sections,
- vec![vec![(config.hunk_header_style, &lines[0].0)]], // TODO: compute style from state
- [State::HunkHeader].iter(),
- &mut painter.output_buffer,
- config,
- &mut None,
- None,
- None,
- Some(false),
- );
- painter.output_buffer.pop(); // trim newline
+ if !line.is_empty() {
+ let lines = vec![(line, State::HunkHeader)];
+ let syntax_style_sections = Painter::get_syntax_style_sections_for_lines(
+ &lines,
+ &State::HunkHeader,
+ &mut painter.highlighter,
+ &painter.config,
+ );
+ Painter::paint_lines(
+ syntax_style_sections,
+ vec![vec![(config.hunk_header_style, &lines[0].0)]], // TODO: compute style from state
+ [State::HunkHeader].iter(),
+ &mut painter.output_buffer,
+ config,
+ &mut None,
+ None,
+ None,
+ Some(false),
+ );
+ painter.output_buffer.pop(); // trim newline
+ }
draw_fn(
painter.writer,
&painter.output_buffer,