gdh1995 / vimium-c

A keyboard shortcut browser extension for keyboard-based navigation and tab operations with an advanced omnibar
https://chrome.google.com/webstore/detail/vimium-c/hfjbmagddngcpeloejdejnfgbamkjaeg
Other
3.17k stars 253 forks source link

Key remapping causes LinkHint to show misleading hints based on original key layout #1148

Open omnilisk opened 2 weeks ago

omnilisk commented 2 weeks ago

LinkHint mode doesn't respect custom key remappings when showing hints but expects new custom keys when actually opening links. For example, after swapping H with another key, I found that when hint 'H' appears over a link, Vimium C actually expects the new key (in my case, J), and pressing H will either do nothing or activate a wrong link.

This issue can be sidestepped by remapping the relevant keys back to themselves for LinkHint mode using :l. Here's a mapping config that worked for me:

# Remap some keys
mapKey j h
mapKey k j
mapKey l k
mapKey ; l
mapKey : L
mapKey h ;

# Revert remappings - only for LinkHint mode
# and just for keys that appear in hints
mapKey <j:l> j
mapKey <k:l> k
mapKey <l:l> l
mapKey <h:l> h

Note: after remapping a non-letter key like ';', it will not work while holding Shift, unless the secondary character for that key has its own mapping. Hence the two separate lines for ';' and ':' above.

It would be nice if Vimium C's link hints' default behavior were to show the same letters as the ones that actually open the link - taking into account any custom key bindings added by the user.

Chrome 125.0.6422.142 (Official Build) (64-bit) Win 11 10.0.22631 Vimium C 1.99.99

gdh1995 commented 2 weeks ago

Sorry I'm not sure what you want.

current logic

With the below mapping,

mapKey j h
mapKey k j
mapKey h k

And LinkHints shows a hint marker named H, then if you press j, the H hint marker will be triggered.

your issue

Then how do you think about it? Do you want h to trigger H, or LinkHints to name the hint not H but J ?

recommended usages

In fact, mapKey j h and mapKey h j are very easy to cause misunderstanding.

You may need mapKey <j:n> k to limit the mapping in normal mode only.

As for mapKey of non-letter keys, it works as intended that Shift+key doesn't match the mapKey rule. This feature is a balance between convenience and implementation complexity.