-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle a mode change on a renamed file. #875
Conversation
9569334
to
ac8e4a3
Compare
Hi @WayneD, thanks for working on this! I haven't thought about how this should work -- can I check, is this the intended behavior?
|
Yeah, that's what I ended up with given the current way the parsing works. My thoughts on an alternative method that delays the mode info pending more parsing would allow the 2 bits of info to be output in a more unified manner. Combined with your thoughts on wanting improved prefix handling, I think it would be better to go with the delayed-mode method (which should mean that the diff line is only ever used when no renaming is going on, and thus the current splitting function wouldn't need to change). |
ac8e4a3
to
4194b8e
Compare
That sounds good. I agree that, seeing as you're working on this, it makes sense to try to achieve an output format that you're really happy with. What do you think, something like this maybe? (This is just the first thing that occurred to me; I haven't thought through the problem/solution space properly.)
|
3453ac7
to
9de7127
Compare
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.
56be12c
to
2933dd3
Compare
I fixed the conflicts with the DeltaTest strings now that the delta-test branch has merged. You'll note that my latest version uses parentheses to display the mode info, which I thought was a good choice in the various output idioms. It should be ready to merge now, IMHO. |
Excellent, thanks a lot for this work @WayneD! |
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:
Would it look better on its own line?
Would it look better appended after a "•" character?
Should it be a user option? If so, we can do that later.