add option for persistent recent section
fixes #1687
This PR adds a new option config.sections.recent.always, which defaults to false. This keeps the current behavior which only shows the recent section if there is no unmerged commits. which looks like this
Setting this option to true will always show the recent section. which looks like this
I didn't find a documentation section, where I could provide additional context for the option or the current behavior. Happy to add this, if you can point me to somewhere.
I also prefer the 'Recent Commits' section for rebasing and other actions, but displaying both the Recent and Unmerged sections simultaneously causes a rendering bug:
In the screenshot, both Unpush and Recent sections has commit test, and I choosed the first one in the 'Unpushed' section, but the last one in the 'Recent' section get rendered.
This bug is kind hard to fix, as neogit use oid (commit hash) to identify each commit components, after the components oid indexed, if buffer components oid is not unique, it will always point to the last component. I've tried to fix this, but there's no cursor status stored, so I give up.
A workaround for this is hide the Unmerged section as unmerged_upstream = { hidden = true }, so the Recent Commits section is always shown, and it will correctly rendered.
@SheffeyG thats interesting. I'm currently away and will have a look if there is a nice way to fix this when i'm back. Personally i didn't like the same commit showing up in recent and unmerged, maybe there is a way to just show new commits in unmerged and recent to show previous commits.
So... I think I made a pretty core assumption that an object's OID would only be in a given buffer once: https://github.com/NeogitOrg/neogit/blob/df08cb97f126c546a5ec265bafab2d78cc7399fa/lua/neogit/lib/ui/renderer.lua#L54-L56
That index is used to apply the "active item" highlight. https://github.com/NeogitOrg/neogit/blob/df08cb97f126c546a5ec265bafab2d78cc7399fa/lua/neogit/lib/buffer.lua#L896
And given that it's a hash-like lua table, last entry for a given OID wins. This is what @SheffeyG was pointing out, and... I don't think there's an easy fix.
@laughingman-hass You could in theory XOR the "unmerged" and "recent" commits, but both are fetched concurrently when we re-sync internal state to repo state, so you'd need to have some kind of callback that operates on both tables after they are updated. Kind of a PITA if you ask me.