diff options
author | Yoichi NAKAYAMA <yoichi.nakayama@gmail.com> | 2020-08-08 22:59:10 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-08 09:59:10 -0400 |
commit | 8edff6233d89dd61b88d973ce4416fe6391640a1 (patch) | |
tree | ae2bbe984bfcf9651af5374b3587439be42d011a /src/delta.rs | |
parent | 0e980778538437968e242044fd125d58d672b50e (diff) |
Calculate line numbers correctly in raw/color-only mode (#272)
* Calculate line numbers correctly in raw/color-only mode
- call handle_hunk_header_line() if line number option is set
- insert empty line before hunk header line only if decoration style is set
* Move condition into should_handle()
Diffstat (limited to 'src/delta.rs')
-rw-r--r-- | src/delta.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/delta.rs b/src/delta.rs index 814401fe..db3c752c 100644 --- a/src/delta.rs +++ b/src/delta.rs @@ -188,6 +188,9 @@ where /// Should a handle_* function be called on this element? fn should_handle(state: &State, config: &Config) -> bool { + if *state == State::HunkHeader && config.line_numbers { + return true; + } let style = config.get_style(state); !(style.is_raw && style.decoration_style == DecorationStyle::NoDecoration) } @@ -413,7 +416,9 @@ fn handle_hunk_header_line( let (raw_code_fragment, line_numbers) = parse::parse_hunk_header(&line); // Emit the hunk header, with any requested decoration if config.hunk_header_style.is_raw { - writeln!(painter.writer)?; + if config.hunk_header_style.decoration_style != DecorationStyle::NoDecoration { + writeln!(painter.writer)?; + } draw_fn( painter.writer, &format!("{} ", line), |