micro icon indicating copy to clipboard operation
micro copied to clipboard

Rebinding of default keys is not reflected in the Key Menu

Open AndrewDDavis opened this issue 1 year ago • 7 comments

Description of the problem or steps to reproduce

When rebinding default keys, the menu that shows with the ToggleKeyMenu action doesn't reflect the changes.

Steps to reproduce:

  1. Change some default keybindings, e.g.:
{
    "Alt-z":    "Redo",
    "Ctrl-y":   "None",

    "Alt-?":    "ToggleHelp",
    "Ctrl-g":   "FindLiteral",
}
  1. Launch micro. Observe that the bindings are in effect: Ctrl-y does nothing, while Alt-z performs redo. Ctrl-g starts a search, while Alt-? shows the help.

  2. Hit Alt-g to show the key menu.

  3. However, observe that the menu still shows ^Y Redo and ^G Help, which do not correspond to the bindings currently in effect.

Specifications

Version: 2.0.13 Commit hash: 68d88b57 OS: ChromeOS Terminal: ChromeOS Terminal

AndrewDDavis avatar Dec 01 '23 04:12 AndrewDDavis

It isn't a bug (in the sense of code), it is just a static and hard coded string internal/display/infowindow.go#L181.

You can even find several lines below comment with // TODO: maybe make this based on the actual keybindings :)

dustdfg avatar Dec 01 '23 07:12 dustdfg

The // TODO can be seen as possible improvement. Help is appreciated to do the necessary change, test it and provide it as a PR.

I suggest to turn the keydisplay into a lookup map, where the user string (e.g. Save, Cut Line, etc) is the key and the respective builtin command the value. Then it can be compared against action.Binder["buffer"], where the actual key binding is stored. This then could be used as key to display in front of the above mentioned strings.

JoeKar avatar Dec 01 '23 17:12 JoeKar

@semirke It looks like you started to do it in your fork https://github.com/semirke/micro/pull/1/commits/0fad40946fd02d76c6b3d1177a501e0eec01f136. Although it is buggy... screen-1702735517 But would you work on it further? (and when will finish the feature to backport it as PR? ;)

dustdfg avatar Dec 16 '23 14:12 dustdfg

@dustdfg There was already an old PR about it, I merged it in my repo.

semirke avatar Dec 17 '23 00:12 semirke

Ok. I assume this https://github.com/zyedidia/micro/pull/2152. Although it won't just compile without adding one line to function that will complain about not defined keydisplay

 func (i *InfoWindow) Display() {
+       keydisplay := keydisplayGen()

dustdfg avatar Dec 17 '23 05:12 dustdfg

Ok. I assume this #2152. Although it won't just compile without adding one line to function that will complain about not defined keydisplay

 func (i *InfoWindow) Display() {
+       keydisplay := keydisplayGen()

Yes, I had to fix it. Making that buffer pageable would be quite nice and adding all keys. I didnt have trouble with missing keys, so I didnt bump into your find.

semirke avatar Dec 17 '23 08:12 semirke

@semirke It looks like you started to do it in your fork semirke@0fad409. Although it is buggy... screen-1702735517 But would you work on it further? (and when will finish the feature to backport it as PR? ;)

Ok, I checked, the original PR was correct, something went wrong when I merged it. Fixed in my branch,too.

semirke avatar Dec 17 '23 09:12 semirke