-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Support custom keybindings in custom command menu prompts #5129
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
Support custom keybindings in custom command menu prompts #5129
Conversation
|
I'm quite sure that the changes can be hot-reloaded since they are part of an already existing config struct. Please let me know if this is wrong and I'll try to fix it! |
|
Done |
8581a16 to
22008c2
Compare
stefanhaller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. The change in the second commit looks good; I find it a bit unfortunate that we have a "key" field in the menu prompt itself, which means something very different than the new "key" fields in the individual prompt items; maybe we should rename the former to "id" or something like that to make this less confusing. But that would be a breaking change, so I'm hesitant to do that. Maybe we'll just live with the awkwardness.
I pushed a fixup (eb5b0f1) to move the doc changes to the right place; see #5010 for more about that.
There's some validation code missing for checking that the keys are valid; without that, if you set a key to "xyz" it will crash when you open the menu. We need to guard against that by adding validation code to user_config_validation.go, similar to how we already do it for other keybindings. I don't have time to add this right now; if you want to give that a try yourself, feel free to go ahead, but if you would just ask copilot to do it, then please don't. (I'm not fond of reviewing ai-generated code.)
As for the first commit, I don't think this is the right approach. It has two problems:
- it works for 'H' and 'L', but not for 'j' and 'k' (although this would easily be solved by removing NextItemAlt and PrevItemAlt from your list of essential keys)
- it would still keep the keys visible that conflict with essential bindings, and that's confusing; we need to remove them from display too.
Since this is a problem that's unrelated to the feature you are adding here (we have the same problem already with custom command menus), I opened another PR for solving these in a better way; see #5131.
| IsFocused(). | ||
| Press("a") | ||
|
|
||
| // Verify the menu appears |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We tend to not comment our tests so much. These comments only add noise, I added a fixup to remove most of them (d7a787f).
I agree that
I've added validation in a fixup commit (
In this case do you want me to revert these changes and let that be fixed in your linked PR? |
Very nice! I pushed another fixup for this (283991b) to make the error text more consistent with the other keybinding checks we already have.
Yes, please drop those changes. (Feel free to squash the fixups too.) Your tests will not be green without #5131 because the |
|
Sure thing! I'll try to get to the review and cleaning this up tomorrow! 👍 |
|
@HerrNaN Thanks! Both PRs are merged, so you can go ahead and rebase this one onto master. |
283991b to
62913ee
Compare
|
@stefanhaller rebased and ready! |
|
@stefanhaller Thank you for maintaining such a great tool and for fast feedback and merging of my PR! |
Summary
resolves: #3626
This adds support for keybindings on menu options.
Example Usage:
Please check if the PR fulfills these requirements
go generate ./...)