diff options
| author | Wayne Davison <wayne@opencoder.net> | 2022-01-05 13:54:18 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-05 16:54:18 -0500 |
| commit | c76a26bd2d5d9d37fa62725bb3fa7fd179c0fbc8 (patch) | |
| tree | 33a5ecb60958148120c816d1aaa4f076d6919f9e /src/handlers/diff_header_diff.rs | |
| parent | 040ad767418b37d57c3215cbf6af2dfb9f0b6813 (diff) | |
Handle a mode change on a renamed file. (#875)
* Handle a mode change on a renamed file.
I changed the diff parsing to cache the mode info from the old/new mode
lines until the parsing bumps into the start of the actual related diff,
finds the diff line for an unrelated diff, or runs out of input. This
allows the mode info to be output in conjunction with a file event
instead of as a separate heading (that used to have an empty name when
the mode change was for a rename).
The mode info is passed down into the draw routines as a separate
"addendum" string that the draw code can use as it likes. Currently that
means that it appends the addendum string to the non-raw string in
parens. I imagine that future draw routines could decide to put it in a
separate box or some other per-routine method. There is currently a
single function in src/handlers/draw.rs that joins the strings in the
same way for everyone.
A couple examples of how the new code looks:
Δ foo.rs (mode +x)
───────────────────────────────────────────────────
renamed: old-longer-name → shorter-name (mode +x)
───────────────────────────────────────────────────
Would it look better on its own line?
Δ foo.rs
• mode +x
───────────────────────────────────────────────────
renamed: old-longer-name → shorter-name
• mode +x
───────────────────────────────────────────────────
Would it look better appended after a "•" character?
Δ foo.rs • mode +x
───────────────────────────────────────────────────
renamed: old-longer-name → shorter-name • mode +x
───────────────────────────────────────────────────
Should it be a user option? If so, we can do that later.
Diffstat (limited to 'src/handlers/diff_header_diff.rs')
| -rw-r--r-- | src/handlers/diff_header_diff.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/handlers/diff_header_diff.rs b/src/handlers/diff_header_diff.rs index 7136716..fdd2d39 100644 --- a/src/handlers/diff_header_diff.rs +++ b/src/handlers/diff_header_diff.rs @@ -22,6 +22,7 @@ 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() { |
