display: make Key Menu reflect real bindings #2152
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This changes the keybinding menu (alt-g) to reflect real keybindings.
Potentially contentious things:
This also patches the
$(bind:)special of the status line.Why does it need patching?
In go, when you iterate a map, the order is non-deterministic.
With the current handling of
$(bind:), if you have >1 binding for the action, which one you get is essentially random.The way you solve this is to ensure a deterministic order by sorting the set of keys.
This needs to happen every invocation, in case the user changes a binding.
An alternative method would be to keep a cache that is updated whenever bindings are written to.
Lack of this specific feature is a commonly cited reason (to me, personally) of micro not being adopted (thus why it doesn't show up in the issues - it's non-users as of right now), so I figured I would at least offer a way to fix it.
There's already a TODO for it (I didn't remove it in this patch, see next paragraph), so it seems like something that's desirable.
I don't really have the time or energy to modify this patch to suit the exact needs/requirements for merging.
However, it can/should be reasonably trivial to move it anywhere / change some of these minor specifics.
Another thing that could be brushed up (perhaps later?) is the exact way
keydisplayGenperforms the generation.Either way - please consider this code to be CC0/Unlicense/BSD0/Blue-Oak-Model 1.0.
I'd rather see it (as in the feature/behaviour on the overall) get merged, ideally with as little involvement from my end from this point on :)